Using Environments

Railway supports complex development workflows through environments, giving you isolated instances of all services in a project.

Create an Environment

  1. Select + New Environment from the environment drop down in the top navigation. You can also go to Settings > Environments.

  2. Choose which type of environment to create -

    • Duplicate Environment creates a copy of the selected environment, including services, variables, and configuration.

      When the duplicate environment is created, all services and their configuration will be staged for deployment. You must review and approve the staged changes before the services deploy.

    • Empty Environment creates an empty environment with no services.


Sync Environments

You can easily sync environments to import one or more services from one environment into another environment.

  1. Ensure your current environment is the one that should receive the synced service(s)
  2. Click Sync at the top of the canvas
  3. Select the environment from which to sync changes
  4. Upon sync, each service card that has received a change will be tagged "New", "Edited", "Removed"
  5. Review the staged changes by clicking Details on the staged changes banner
  6. Click "Deploy" once you are ready to apply the changes and re-deploy
Staged changes on Railway canvas

Enable PR Environments

Railway can spin up a temporary environment whenever you open a Pull Request. To enable PR environments, go to your Project Settings -> Environments tab.

Screenshot of Deploy Options

When enabled, a temporary environment is spun up to support the Pull Request deploy. These environments are deleted as soon as these PRs are merged or closed.

How Come my GitHub PR Won't Deploy?

Railway will not deploy a PR branch from a user who is not in your team or invited to your project without their associated GitHub account.

Copy Volume Data

When enabled, any volume data from the base environment is copied to a new PR Environment. This is particularly useful if you've setup a staging environment with some seed data and want it copied into your new PR Environment.

Before using the feature, here are some things to consider:

  • If you're using this feature, we strongly recommend against using a production environment as your base environment.
  • Using the Copy Volume Data feature means PR Environments will have a copy of your base environment data with no fancy modifications.
    • For a Postgres database, that means the username/password of a PR Environment will have to be the same as the base environment.
    • For others tools like Redis, this is not an issue.
  • If you're using Railway's Postgres template, we'll make sure that password in the PR Environment matches the base one.
Copy Volume Data

Bot PR Environments

You can enable automatic PR environment creation for PRs opened by GitHub bots (Dependabot, Renovatebot) using the Enable Bot PR Environments toggle on the Environments tab in the Project Settings page.

Bot PR Environments toggle

Forked Environments

As of January 2024, forked environments have been deprecated in favor of Isolated Environments with the ability to Sync.

Any environments forked prior to this change will remain, however, you must adopt the Sync Environments flow, in order to merge changes into your base environment.


Edit this file on GitHub