---
title: "Deploy PayloadCMS + Postgres"
description: "PayloadCMS v2 with PostgreSQL Database Service"
category: "CMS"
url: https://railway.com/deploy/B_KVXT
---

# Deploy PayloadCMS + Postgres

PayloadCMS v2 with PostgreSQL Database Service

**[Deploy PayloadCMS + Postgres on Railway](https://railway.com/template/B_KVXT)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/B_KVXT/manifest.json

- **Creator:** Aaron K Saunders's Projects
- **Category:** CMS
- **Total deploys:** 103

## Template content

### Postgres https://devicons.railway.app/i/postgresql.svg

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:latest

### payload-railway-postgres

- **Source:** https://github.com/aaronksaunders/payload-railway-postgres
- **Start command:** `yarn run serve`
- **Public domain:** Yes

## Documentation

# Payload CMS v2 with PostgreSQL Database


[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/template/B_KVXT?referralCode=1-iY_G)

The original project was created using `npx create-payload-app` and used the blank template.

## How to Use Locally with Remote PostgreSQL Database
> Following these instructions will have the application pointing to the hosted PostgreSQL database
- `yarn install` to install the needed dependencies
- Install and configure the [Railway CLI](https://docs.railway.app/develop/cli)
- `railway run yarn dev` will start up your application and reload on any changes. At this point changes in the schema will be automatically updated in the remote PostgreSQL database
-  to create migration before committing your code `railway run yarn payload migrate:create`

## How to Use Locally with Local PostgreSQL Database
- `yarn install` to install the needed dependencies
- Create your own local Postgres Database and update the `.env` file with the `DATABASE_URI`
- Set the other `.env` file variables
- `yarn dev` will start up your application and reload on any changes
- Payload will update the database schema locally so you will need to run `railway run yarn payload migrate:create` before committing to GitHub so the schema changes get committed. The deployment script will run the appropriate migrate command to push changes to the database


## PostgreSQL Information
- https://www.postgresql.org/download/
### How To Create a Local PostgreSQL Database

Open the terminal and run the command
```
sudo -u postgres psql
```

Create PostgreSQL Database
```
CREATE DATABASE myproject;
```

Create User
```
CREATE USER myprojectuser WITH PASSWORD 'password';
```

Update the `.env` file variable `DATABASE_URI` appropriately to point to the correct server


## Similar templates

- [Libredesk - Complete Setup](https://railway.com/deploy/libredesk-complete-setup) — Complete self-hosted omnichannel customer support desk.
- [Paperless-ngx](https://railway.com/deploy/paperless-ngx-3) — Paperless-ngx — document management with OCR and full-text search
- [Instatic CMS - Postgres](https://railway.com/deploy/instatic-cms-postgres) — Design, build and manage powerful static sites from state-of-the-art CMS

Open this page in a browser: https://railway.com/deploy/B_KVXT
