Railway
02 / 02

Railway Basics: Deploy, Services & Databases

Railway: Deploy, Services & Databases

Railway is a cloud deployment platform that provisions infrastructure automatically from a connected Git repository, minimizing the manual DevOps configuration needed to go from code to a running deployment -- a modern take on Heroku's original 'git push to deploy' experience.

Push-to-Deploy

Once a GitHub repo is connected, a push to the configured branch (commonly main) automatically triggers a build and deployment -- continuous deployment out of the box, without setting up a separate CI/CD pipeline just to get changes live.

Automatic Build Detection: Nixpacks

Nixpacks inspects a project's files (package.json, requirements.txt, go.mod) to auto-detect the language/framework and produce an appropriate container build, without the developer writing a Dockerfile. A custom Dockerfile is still supported for full control.

Services & Databases

A typical Railway project:

  web        -- the application itself (deployed from the Git repo)
  worker     -- a background job processor (same repo, different start command)
  postgres   -- a one-click provisioned managed database

Each service has its own deployment lifecycle, environment variables,
and resource usage, but shares the project for organization. Adding
Postgres provisions it and automatically injects a DATABASE_URL
variable into the other services -- no manual connection-string wiring.

Environment Variables

Set per-service through the dashboard or CLI, including shared variables referenced across multiple services. Database connection details from Railway-provisioned services are injected automatically -- secrets never need to be committed to the repository.

Railway CLI

npm install -g @railway/cli
railway login
railway link          # link a local project to a Railway project

# Run a command locally with the project's Railway env vars injected --
# local dev closely mirrors the deployed environment's config
railway run npm start

railway logs          # stream deployment/runtime logs
railway up            # trigger a deployment from the CLI

Keep your own version of these notes — editable, searchable, and organised by your stack.

Start free