Deploying on Render or Railway

Deploy long-running Node.js servers, background workers and PostgreSQL on a platform-as-a-service from a Git repo or Dockerfile.

Intermediate · about 3 hours · difficulty 2/5

Learn first: Environments, Config and Secrets, Node.js Runtime Essentials

Platforms like Render and Railway run your app as a long-lived server process rather than serverless functions. This suits Express or Fastify APIs, WebSockets and background workers.

What you deploy

  • A web service from a Git repo (build and start commands) or a Dockerfile.
  • A background worker for queues and scheduled jobs.
  • A managed PostgreSQL and Redis instance in the same region.
  • Cron jobs for periodic tasks like sending deadline reminders.

Doing it properly

  • Bind to the PORT environment variable provided by the platform.
  • Add a health check endpoint so the platform knows when your app is ready.
  • Run migrations in a pre-deploy command.
  • Use an infrastructure file (render.yaml) to describe services in code.

Trade-offs

Long-running servers have no cold-start function limits and can hold WebSocket connections. Free tiers often sleep after inactivity, so the first request is slow; paid instances stay warm. Choose a region close to your users (Singapore or Mumbai where available).

Pitfalls

  • Hard-coding port 3000.
  • Running the free sleeping tier for a demo you show to recruiters without warming it first.
  • Storing uploaded files on the server's local disk, which is lost on redeploy.

You are ready to move on when your Express or Fastify API, a worker and PostgreSQL are deployed from Git with health checks, pre-deploy migrations and environment-specific config.

Key concepts

  • Web services from Git or Docker
  • Background workers
  • Managed PostgreSQL and Redis
  • Health checks
  • Pre-deploy migrations
  • Infrastructure as code (render.yaml)
  • Railway or Fly.io

Other options for this step

  • Deploying on Vercel: Deploy a Next.js app with Git-based deploys, preview URLs per pull request, environment variables and edge caching.

Mini project

Deploy your Express or Fastify API with a background worker and managed PostgreSQL on Render, using a health check endpoint, pre-deploy migrations and a render.yaml blueprint.

Check yourself

Why would you lose student resume uploads after a redeploy if you saved them to the server's disk, and where should they go instead?

Free resources