RStudio Viewer shows blank plots. The browser can show them though

#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?

Hey @b_a,

Perhaps this discussion will be of interest https://github.com/ropensci/plotly/issues/717

Thanks @bcd,

However, that seems to be another issue not related to localhost/127.0.0.1 but to the use of ArrayBuffer.
Any other suggestions are still welcome.

I find that it depends on my network configuration (see update). Anyone know how this might be possible?