Failed to render error 500 page: Can't set headers after they are sent.

I'm assuming the error in the subject line is associated with the unhelpful message I'm seeing in my browser ("ERROR: An error has occurred. Check your logs or contact the app author for clarification.") I'm not sure what this error is saying. The app in question runs very well in the rStudio IDE with no warnings. Any ideas of where to look for this problem.

As the error message says, check your logs for that app located at /var/log/shiny-server

I did check the log in /var/log/shiny-server and that's where the contents of the subject line of my original message appeared:
"Failed to render error 500 page: Can't set headers after they are sent"

Is that the only line in your log? a little more context would be helpful

After a little googling that error seems to be related with the permissions for the run_as user (shiny by default).
Have you set propper permissions for shiny user?

sudo groupadd shiny-apps
sudo usermod -aG shiny-apps your_user # your normal user goes here
sudo usermod -aG shiny-apps shiny
cd /srv/shiny-server
sudo chown -R your_user:shiny-apps .
sudo chmod g+w .
sudo chmod g+s .

Also have in mind that all the libraries used in your app have to be installed system wide in the server in order for shiny been able to use them.

I saw the same issues in Google but was skeptical as to their relevance. I'll try your suggestions later on in the evening and see if it works. Thanks for the prompt response.

This sounds like it might be a bug that we fixed a few versions of Shiny Server ago--I believe in 1.5.7. If you haven't upgraded in a while, that is where I'd start. Sorry for the inconvenience.

Not much else in it.

e[32m[2019-01-31 20:18:15.686] [INFO] shiny-server - e[39mShiny Server v1.5.3.838 (Node.js v6.10.0)
e[32m[2019-01-31 20:18:15.689] [INFO] shiny-server - e[39mUsing pidfile /var/run/shiny-server.pid
e[32m[2019-01-31 20:18:15.690] [INFO] shiny-server - e[39mUsing config file "/etc/shiny-server/shiny-server.conf"
e[33m[2019-01-31 20:18:15.744] [WARN] shiny-server - e[39mRunning as root unnecessarily is a security risk! You could be running more securely as non-root.
e[32m[2019-01-31 20:18:15.748] [INFO] shiny-server - e[39mStarting listener on 0.0.0.0:3838
e[31m[2019-01-31 21:08:50.270] [ERROR] shiny-server - e[39mFailed to render error 500 page: Can't set headers after they are sent.
e[32m[2019-01-31 21:08:50.303] [INFO] shiny-server - e[39mCreated bookmark state directory: /var/lib/shiny-server/bookmarks
e[32m[2019-01-31 21:08:50.314] [INFO] shiny-server - e[39mCreated user bookmark state directory: /var/lib/shiny-server/bookmarks/shiny
e[31m[2019-01-31 21:09:06.995] [ERROR] shiny-server - e[39mFailed to render error 500 page: Can't set headers after they are sent.
e[31m[2019-01-31 21:11:08.957] [ERROR] shiny-server - e[39mFailed to render error 500 page: Can't set headers after they are sent.

Rereading your original message, I'm guessing that upgrading to a new Shiny Server version will eliminate this "Failed to render error 500" in your log, but not resolve whatever the problem is with your app. The error message is vague on purpose, on the off chance that your error messages happen to contain sensitive information like usernames. If you'd prefer helpful error messages, you can turn off the vagueness by adding the line sanitize_errors false; to the top level of your /etc/shiny-server/shiny-server.conf and reloading or restarting the shiny-server service.

Whether errors are being sanitized or not, you should be able to find log files in /var/log/shiny-server/ (note that, confusingly, this is not the same as /var/log/shiny-server.log). The /var/log/shiny-server.log file is what you've posted, and it contains the output from the shiny-server process itself. The errors that are causing the unhelpful messages in the browser are originating from the R processes, and those are in the /var/log/shiny-server/ directory.

One last complication--sorry. In an effort to not fill up your hard drive with spurious log data, by default Shiny Server deletes the log files in /var/log/shiny-server/ if the R process that generated it exits gracefully. If you're not finding the log files you're looking for, you can turn off this automatic deletion by adding the line preserve_logs true; to your shiny-server.conf, and again, reloading or restarting.

The most common source of errors that only appear on the server are 1) some package that your app uses is installed locally but not on the server (at least not in a place that the shiny user can get to it), or 2) you've got a hard-coded path in your app logic that points to a location that doesn't exist on the server (use a relative path instead).

Your message was filled with great tips. Thanks,

… but it has led to an even more confusion …
ERROR: there is no package called ‘shinyjs’
.. I think this may be caused by the fact that my IDE environment where the same code executes without error and the server copy pointed to by the shiny-server.conf are different.

The IDE Environment is
/home/rstudio/ShinyApps/EllumenWearables

shiny-server.conf is
/srv/shiny-server

As I told you before

This means that the packages used in your app must be installed as superuser, try installing shinyjs from the system console, this way

sudo su - -c "R -e \"install.packages('shinyjs', repos='http://cran.rstudio.com/')\""

Thanks for the help … I didn't understand the import of your previous advise. Sorry

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.