Support

Why does my app work locally, but not on my RStudio Connect server?

Follow

There are many reasons why an application that appears to work locally may have performance issues or other problems when running on RStudio Connect. We recommend starting by checking your application logs for any errors in your application. You can see your logs in the RStudio Connect dashboard under the Logs section for your deployed content. Alternatively, you can check the jobs subdirectory of the RStudio Connect data directory for your 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.
  • Your application may be running as a user who does not have the correct permissions or settings. Check your RunAs settings and see our admin guide here for more information. 
  • Using absolute file paths instead of relative paths. For example, the following two examples may fail, especially if they refer to locations on your local machine rather than on the server:
    • Windows: read.csv("C:\myapplication\data\myfile.csv")
    • Linux or Mac: read.csv("~/myapplication/data/myfile.csv")

    Ideally, your application should reference the data file by a path relative to the application, e.g., read.csv("data/myfile.csv"). If not, you should make sure the path given is one that exists on the server and the file in question exists and is readable in that location.

  • Attempting to change the working directory. This is a corollary to the previous item. The working directory is the directory where your ui.R and server.R files 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:
    • Windows: setwd("C:\myapplication\data")
    • Linux or Mac: setwd("~/myapplication/data")
  • Attempting to access resources that are not reachable from your RStudio Connect server
  • Use of packages that require Windows (RStudio Connect 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 our Troubleshooting Performance with RStudio Connect article)
Have more questions? Submit a request

Comments

Powered by Zendesk