---
title: "Building a NestJS App on Railway"
description: "A NestJS app can run on Railway as a Dockerized service from a GitHub repo, with Redis for caching, Postgres via TypeORM, and in-process cron jobs."
url: "https://swe.quest/articles/building-a-nestjs-app-on-railway-6bac96cda5fec5ce"
canonical: "https://blog.railway.com/p/building-nestjs-on-railway"
source: "Railway"
published: "2024-12-13"
difficulty: "medium"
kind: "How-to"
reading_minutes: 6
tags: ["typescript","deployment","caching","postgres","cloud"]
---

# Building a NestJS App on Railway

A post on [Railway](https://swe.quest/sources/railway.md), published 2024-12-13, 6 min read, How-to. Original: [https://blog.railway.com/p/building-nestjs-on-railway](https://blog.railway.com/p/building-nestjs-on-railway)

## Summary

A NestJS app can run on Railway as a Dockerized service from a GitHub repo, with Redis for caching, Postgres via TypeORM, and in-process cron jobs. The walkthrough supplies a Node 20 Dockerfile, an async CacheModule factory using cache-manager-redis-store with a one-week TTL, and a TypeOrmModule config. Each piece reads its connection details from Railway reference variables such as ${{Redis.REDISHOST}} and ${{Postgres.PGHOST}}. For the fastest path, a one-click Railway template provisions the same stack, and ejecting from it afterward puts the repo under your own GitHub account.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [TypeScript](https://swe.quest/tags/typescript.md) (Languages)
- [Deployment](https://swe.quest/tags/deployment.md) (Reliability & operations)
- [Caching](https://swe.quest/tags/caching.md) (Backend & APIs)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Cloud platforms](https://swe.quest/tags/cloud.md) (Infrastructure)

## Prerequisites

- Node.js and npm ([easy posts on JavaScript](https://swe.quest/tags/javascript.md?difficulty=easy))
- Docker basics ([easy posts on Containers](https://swe.quest/tags/containers.md?difficulty=easy))
- NestJS modules

## Keywords

NestJS, Railway, Redis, PostgreSQL, TypeORM, Docker, cache-manager

## Related posts

- [Migrating From Heroku To Railway](https://swe.quest/articles/migrating-from-heroku-to-railway-dbd89b10c75a9d07.md): Railway · 2022-08-19 · Medium · 7 min read · Deployment, Cloud platforms, Ruby
  Moving a Heroku app to Railway comes down to three steps: deploy from a GitHub repo, import Heroku config vars, and add Postgres and Redis as separate database services.
- [Build a serverless API using Cloudflare Workers, Drizzle ORM, and Neon](https://swe.quest/articles/build-a-serverless-api-using-cloudflare-workers-drizzle-orm-and-neon-f83c472c9d399a17.md): Neon · 2023-05-30 · Medium · 9 min read · Serverless, PostgreSQL, TypeScript, Schema migrations
  A step-by-step setup for a serverless TypeScript API on Cloudflare Workers that uses Hono for routing, Drizzle ORM for schema definition and migrations, and Neon serverless Postgres for storage.
- [A database for every preview environment using Neon, GitHub Actions, and Vercel](https://swe.quest/articles/a-database-for-every-preview-environment-using-neon-github-actions-and-vercel-dd5fe24cba2d12b5.md): Neon · 2023-04-14 · Medium · 14 min read · PostgreSQL, CI/CD, Deployment, Schema migrations
  Neon's copy-on-write branching can give every pull request its own production-like Postgres database, avoiding the bottlenecks of shared staging or shared preview databases.
- [Building a SaaS application on Railway](https://swe.quest/articles/building-a-saas-application-on-railway-c33704a725fc6e9e.md): Railway · 2024-12-13 · Medium · 12 min read · React, PostgreSQL, Deployment, TypeScript, Identity & auth
  A step-by-step tutorial for building a job board SaaS MVP with Remix, PostgreSQL via Drizzle ORM, Clerk authentication and shadcn/ui, then deploying it to Railway.
- [One-Second Deploys? We Didn’t Believe It Either](https://swe.quest/articles/one-second-deploys-we-didn-t-believe-it-either-540280e06702d626.md): Railway · 2025-03-05 · Easy · 3 min read · Serverless, Deployment, TypeScript, Developer productivity
  Railway Functions, now generally available, deploy single-file TypeScript code onto Railway's container compute in about a second, without a package.json, Git repo, IaC or container build.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
