Project variables are provided whenever you build, deploy, or run railway run. Together these variables form your Railway environment. Each plugin provides the necessary environment variables needed to use it (such as DATABASE_URL for the PG plugin). You can also specify custom variables on the project variables page.

Screenshot of Project Variables on Railway Dashboard

You can view all variables for the current environment with railway vars and change the environment with railway environment.

Bulk Import

Chances are you might already have a .env file laying around. You can import your existing environment variables via Bulk Import.

You can click the Bulk Import link to open up a modal where you can paste in a list of variables separated by new line.

Multiline Variables

Railway supports multiline variables/object variables. Just type or paste in the value as you would normally.

Railway Provided Variables

Railway provides the following additional system environment variables to all builds and deployments.

RAILWAY_STATIC_URLThe public domain, of the form
RAILWAY_GIT_COMMIT_SHAThe git SHA of the commit that triggered the deployment. Example: d0beb8f5c55b36df7d674d55965a23b8d54ad69b
RAILWAY_GIT_AUTHORThe user of the commit that triggered the deployment. Example gschier
RAILWAY_GIT_BRANCHThe branch that triggered the deployment. Example main
RAILWAY_GIT_REPO_NAMEThe name of the repository that triggered the deployment. Example myproject
RAILWAY_GIT_REPO_OWNERThe name of the repository owner that triggered the deployment. Example mycompany
RAILWAY_GIT_COMMIT_MESSAGEThe message of the commit that triggered the deployment. Example Fixed a few bugs

Templated Variables

Variables can reference other variables using the ${{ MY_VAR }} templating syntax. This can help reduce duplication if you need the same value in more than one variable, or need to present a plugin-provided variable differently.

Note: The above RAILWAY_* variables aren't yet supported in templates

Construct "Meta" Variables

If you find yourself needing the same value in more than one place, you can create a template to avoid duplication. The following example constructs a URL from an AWS S3 configuration:

"Rename" Plugin Variables

Railway plugins provide a fixed set of variables. If your application requires a variable to be under different name, create a new custom variable that uses a template to reference the original:

Edit this file on GitHub