RailwayDocs

Variables Reference

Template syntax

Railway's templating syntax gives you flexibility in managing variables:

  • NAMESPACE - The value for NAMESPACE is determined by the location of the variable being referenced. For a shared variable, the namespace is "shared". For a variable defined in another service, the namespace is the name of the service, e.g. "Postgres" or "backend-api".
  • VAR - The value for VAR is the name, or key, of the variable being referenced.

You can also combine additional text or even other variables, to construct the values that you need:

Variable functions

Template variable functions allow you to dynamically generate variables (or parts of a variable) on demand when the template is deployed.

Railway-provided variables

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

NameDescription
RAILWAY_PUBLIC_DOMAINThe public service or customer domain, of the form example.up.railway.app
RAILWAY_PRIVATE_DOMAINThe private DNS name of the service.
RAILWAY_TCP_PROXY_DOMAIN(see TCP Proxy for details) The public TCP proxy domain for the service, if applicable. Example: roundhouse.proxy.rlwy.net
RAILWAY_TCP_PROXY_PORT(see TCP Proxy for details) The external port for the TCP Proxy, if applicable. Example: 11105
RAILWAY_TCP_APPLICATION_PORT(see TCP Proxy for details) The internal port for the TCP Proxy, if applicable. Example: 25565
RAILWAY_PROJECT_NAMEThe project name the service belongs to.
RAILWAY_PROJECT_IDThe project id the service belongs to.
RAILWAY_ENVIRONMENT_NAMEThe environment name of the service instance.
RAILWAY_ENVIRONMENT_IDThe environment id of the service instance.
RAILWAY_SERVICE_NAMEThe service name.
RAILWAY_SERVICE_IDThe service id.
RAILWAY_REPLICA_IDThe replica ID for the deployment.
RAILWAY_REPLICA_REGIONThe region where the replica is deployed. Example: us-west2
RAILWAY_DEPLOYMENT_IDThe ID for the deployment.
RAILWAY_SNAPSHOT_IDThe snapshot ID for the deployment.
RAILWAY_VOLUME_NAMEThe name of the attached volume, if any. Example: foobar
RAILWAY_VOLUME_MOUNT_PATHThe mount path of the attached volume, if any. Example: /data

Git variables

These variables are provided if the deploy originated from a GitHub trigger.

NameDescription
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

User-provided configuration variables

Users can use the following environment variables to configure Railway's behavior.

NameDescription
RAILWAY_DEPLOYMENT_OVERLAP_SECONDSHow long the old deploy will overlap with the newest one being deployed, its default value is 0. Example: 20
RAILWAY_DOCKERFILE_PATHThe path to the Dockerfile to be used by the service, its default value is Dockerfile. Example: Railway.dockerfile
RAILWAY_HEALTHCHECK_TIMEOUT_SECThe timeout length (in seconds) of healthchecks. Example: 300
RAILWAY_DEPLOYMENT_DRAINING_SECONDSThe SIGTERM to SIGKILL buffer time (in seconds), its default value is 0. Example: 30
RAILWAY_RUN_UIDThe UID of the user which should run the main process inside the container. Set to 0 to explicitly run as root.
RAILWAY_SHM_SIZE_BYTESThis variable accepts a value in binary bytes, with a default value of 67108864 bytes (64 MB)