There are many reasons why an application that appears to work locally may have performance issues or other problems when running on shinyapps.io. We recommend starting by checking your application logs for any errors in your application You can see your logs in the shinyapps.io dashboard under the Logs tab in the Application view. Alternatively, you can use the
rsconnect::showLogs() function to show the log messages of a deployed application.
Here are some common issues that may be responsible:
- Your application may be dependent on code or environment variables that are only present in your local environment. Make sure your application is defining any environment variables that need to be set, your application is properly sourcing any external code, and your application bundle includes all necessary files.
- Your application may be dependent on packages that are installed and loaded in your environment, but aren’t included as
library()calls in your application. Make sure that you have explicit
library()calls in your application for all packages required for your application.
- Using absolute file paths instead of relative paths. For example, the following two examples will fail:
- Linux or Mac:
Instead, your application should reference the data file by a path relative to the application, e.g.,
read.csv("data/myfile.csv"). See the section of our Admin Guide on Storage for more information.
- Attempting to change the working directory. This is a corollary to the previous item. The working directory is the directory where your
server.Rfiles reside. If you need to reach files in a subdirectory, you should use relative paths rather than changing the working directory. For example, the following two examples will fail:
- Linux or Mac:
- Attempting to access resources that are not reachable from shinyapps.io (for example, a database behind your organization’s firewall)
- Use of packages that require Windows (shinyapps.io runs on Linux)
- Use of packages that require access to the display (e.g., packages that require Tcl/Tk)
- Your application may be failing when it comes under the load of several users. This could happen for a variety of reasons, including but not limited to:
- Forgetting to close each database connection after loading in data (the connection limit may be hit)
- Making multiple long-running calls to a public API (the API request limit may be hit)
- Sub-optimal application instance or worker provisioning (see the Troubleshooting Performance section of our shinyapps.io admin guide)