Skip to main content
Version: Next

Railway

note

Last checked with Wasp 0.26 and Railway (as of Apr 6, 2026).

This guide depends on external libraries or services, so it may become outdated over time. We do our best to keep it up to date, but make sure to check their documentation for any changes.

Automatic Deployment server client database

We recommend that you use Wasp Deploy to deploy your Wasp app to Railway. Wasp CLI automates deploying your app and its database with one command.

Manual Deployment server client database

This guide shows you how to deploy your app and provision a database on Railway.

A built Wasp app is a single server that serves your app's pages, its static assets and its API, so it needs a single Railway service.

Prerequisites

To get started, follow these steps:

  1. Make sure your Wasp app is built by running wasp build in the project dir.
  2. Create a Railway account.
  3. Install the Railway CLI.
  4. Run railway login and a browser tab will open to authenticate you.

Create New Project

Let's create our Railway project:

  1. Go to your Railway dashboard, click on New Project, and select Deploy PostgreSQL from the dropdown menu.
  2. Once the project is created, left-click on the Create button in the top right corner and select Empty Service.
  3. Click on the new service, and change the name to app.
  4. Deploy the changes by pressing the Deploy button on top.

Deploy Your App to Railway

Setup the Domain

We'll need the domain for the app service:

  1. Go to the app instance's Settings tab, and click Generate Domain.
  2. Enter 8080 as the port and click Generate Domain.
  3. Copy the domain, as we will need it later.

Deploying the App

  1. Move into the .wasp/out directory:

    cd .wasp/out
  2. Link the .wasp/out directory to your newly created Railway project:

    railway link

    Select app when prompted to select a service.

  3. Go into the Railway dashboard and set up the required env variables:

    Click on the app service and go to the Variables tab:

    1. Click Variable reference and select DATABASE_URL (it will populate it with the correct value)

    2. Add PORT with the value 8080, the port you generated the domain for.

    3. Add WASP_SERVER_URL with the app domain (e.g. https://app-production-XXXX.up.railway.app). https:// prefix is required! There's no separate client URL to configure: WASP_WEB_CLIENT_URL defaults to WASP_SERVER_URL, and one server serves both your app's pages and its API.

    4. Add JWT_SECRET with a random string at least 32 characters long

    Using an external auth method?

    If your app is using an external authentication method(s) supported by Wasp (such as Google or GitHub), make sure to additionally set the necessary environment variables specifically required by these method(s).

  4. Push and deploy the project:

    railway up --ci

    We use the --ci flag to limit the log output to only the build process.

    Railway will locate the Dockerfile in .wasp/out and build one image with your whole app in it: its pages, its static assets and its API.

And now your Wasp app should be deployed!

Back in your Railway dashboard, click on your project and you should see your newly deployed services: PostgreSQL and the app.

Updates & Redeploying

When you make updates and need to redeploy:

  1. Run wasp build to rebuild your app.

  2. Go into the .wasp/out directory and deploy it with:

    railway up --ci