当前位置: 动力学知识库 > 问答 > 编程问答 >

RStudio Viewer cannot show localhosts locations, but can show 127.0.0.1 locations

问题描述:

Problem

For some reason my RStudio (v1.0.136) stopped showing plotly (v4.5.6) graphs in the Viewer.

When I right-click and Inspect element I can see the following error:

Failed to load resource: A server with the specified hostname could not be found.

http://localhost:14985/session/viewhtmle0e7ad97b99/index.html?viewer_pane=1

Opening that link in Chrome shows the plot, so the file is there.

When I run these commands in RStudio:

viewer <- getOption("viewer")

viewer("http://localhost:14985/session/viewhtmle0e7ad97b99/index.html?viewer_pane=1")

I get the same error. But, if I replace localhost with 127.0.0.1:

viewer <- getOption("viewer")

viewer("http://127.0.0.1:14985/session/viewhtmle0e7ad97b99/index.html?viewer_pane=1")

The plot shows as expected in the Viewer window.

Attempts

I have restored my /etc/hosts file (content, ownership and permissions). This did not result in any other behaviour.

I have checked the output of lsof | grep localhost:

RStudio 57564 user 12u IPv4 0x746dc97144b1de71 0t0 TCP localhost:53434->localhost:27978 (ESTABLISHED)

RStudio 57564 user 13u IPv4 0x746dc97144b1de71 0t0 TCP localhost:53434->localhost:27978 (ESTABLISHED)

rsession 57575 user 5u IPv4 0x746dc97144868c81 0t0 TCP localhost:27978 (LISTEN)

rsession 57575 user 6u IPv4 0x746dc9714568c769 0t0 TCP localhost:27978->localhost:53434 (ESTABLISHED)

rsession 57575 user 19u IPv4 0x746dc97145a1c061 0t0 TCP localhost:14985 (LISTEN)

And to me it seems that the rsession is listening to the correct port on localhost.

I have also turned off the Mac OS firewall, this did not have any effect.

I have turned off Little Snitch (a firewall for outgoing connection) as well, this did not have any effect.

Update 2017-02-15:

I have found that this behaviour is dependent on the network I am connected to.

  • Work Ethernet - all OK
  • Home wifi - Issue as described above
  • Android wifi hotspot - all OK
  • Wifi adapter switched off - new error in the Inspect element window: Failed to load resource: The Internet connection appears to be offline``

What network setting can affect plotly's interaction with RStudio's Viewer?

分享给朋友:
您可能感兴趣的文章:
随机阅读: