10 Troubleshooting Errors

We will often receive error messages when trying to access Shiny apps via the web, such as

An error has occurred!
Check your logs or contact the app author for clarification.

or

An error has occurred.
The application failed to start.
The application exited during initialization.

If you are using the SSCC Shiny server, common causes of errors include:

  • Loading a package that is not available to the Shiny server (see list here) and is not installed locally.
  • Loading a package that is installed locally but failing to specify the local library path.
  • Not setting the permissions for Everyone to Read.

In order to definitively identify the cause of the error, we can check the logs. Shiny will save logs with error messages in Z:/ShinyApps/log/. The format of the log file names is appName-shiny-date-time-ID.log, such as test-shiny-20210101-123456-38493.log. It is helpful to sort the files by Date Modified to find the most recent log. Right-click on the appropriate log and open it with Notepad++. The messages and error messages inside will indicate why the app did not run properly.

Two examples of log files are below.

The error in the log file below is either from not installing the package shinyWidgets in a local library, or from installing it but not specifying the library path. Verifying that the package is installed and located within Z:/ShinyApps/ and that the app.R file provides a path to the library will fix the problem (see Using Packages in Shiny Apps).

su: ignore --preserve-environment, it's mutually exclusive to --login.
Error in library(shinyWidgets) : 
  there is no package called 'shinyWidgets'
Calls: runApp ... sourceUTF8 -> eval -> eval -> ..stacktraceon.. -> library
Execution halted

This error is due to the Z:/ShinyApps/test/ directory and the app.R file not being readable by Shiny. Changing permissions will correct this error (see Configuring Your Shiny Apps Directory).

su: ignore --preserve-environment, it's mutually exclusive to --login.
Warning in readLines(file, warn = FALSE) :
  cannot open file '/home/j/jstruck2/ShinyApps/test/app.R': Permission denied
Error in readLines(file, warn = FALSE) : cannot open the connection
Calls: runApp ... appObj -> func -> sourceUTF8 -> readUTF8 -> readLines
Execution halted

Other errors that can happen include “regular” R errors, such as forgetting to load libraries, missing parentheses or commas, and typos, so it is important to constantly test your app locally by clicking the “Run App” button at the top of the Source pane.

If you are using shinyapps.io, logs are under the “Logs” tab found in an app’s settings, or at the URL https://www.shinyapps.io/admin/#/application/ID/logs, where ID is the app’s ID number (not its name).

If you are using RStudio Connect, navigate to the app info page, and click on “Logs” in the top-right corner of the page, underneath your username.