Shiny-server on ubuntu 16 error: "unable to open connection to X11 display ''

...
I'm trying to run a shiny dashboard on an Ubuntu 16 aws ec2 and the sample is partially working: it shows the dashboard controls but and error message instead of the graphs.

Error log out put at /var/log/shinyserver:

Listening on http://127.0.0.1:35434
Warning in pngfun(filename = filename, width = width, height = height, res = res,  :
  unable to open connection to X11 display ''
Warning: Error in .External2: unable to start device PNG
  123: pngfun
  122: startPNG
  121: drawPlot
  107: <reactive:plotObj>
   91: drawReactive
   78: origRenderFunc
   77: output$distPlot
    1: runApp

From shiny-server.conf at /etc/shiny-server:

# Instruct Shiny Server to run applications as the user "shiny"
run_as ubuntu;

# Define a server that listens on port 3838
server {
  listen 3838;

  # Define a location at the base URL
  location / {

    # Host the directory of Shiny Apps stored in this directory
    site_dir /srv/shiny-server;

    # Log all Shiny output to files in this directory
    log_dir /var/log/shiny-server;

    # When a user visits the base URL rather than a particular application,
    # an index of the applications available in this directory will be shown.
    directory_index on;
  }
}

I tried a few packages prior to R installation: xorg-dev and libx11-dev But they didn't help.
I also tried editing Rprofile.site with options(bitmapType='cairo') but that was also ineffective.

1 Like

Can you execute capabilities() in the version of R that you are using on the server, and share the output? I am curious if you have the system dependencies required to support generating PNG graphics.

Another report of this problem came in over here, this time with capabilities():

Thanks bringing this up, jcblum. Let's hope it solved soon.

Solved by updating keys and installing newer version of r-base (3.4).

Previously I was using a wget command to grab R-3.4 and build from source, but where ever it came from the install didn't have X11 configured properly.

Under capabilities() jpeg and x11 were no, cairo and png were yes I believe

1 Like