---
title: "Deploy Ghost CMS + MySQL"
description: "Ghost 6 with MySQL 8, volumes, private networking, and safer startup."
category: "Blogs"
url: https://railway.com/deploy/ghost-cms-mysql
---

# Deploy Ghost CMS + MySQL

Ghost 6 with MySQL 8, volumes, private networking, and safer startup.

**[Deploy Ghost CMS + MySQL on Railway](https://railway.com/template/ghost-cms-mysql)**

- **Creator:** leodev
- **Category:** Blogs
- **Total deploys:** 20

## Template content

### mysql https://devicons.railway.com/i/mysql.svg

- **Image:** mysql:8.4

### ghost https://docs.ghost.org/favicon.png

- **Image:** ghost:6-alpine
- **Start command:** `/bin/sh -lc 'set -eu; host="${database__connection__host:-mysql.railway.internal}"; port="${database__connection__port:-3306}"; attempt=1; until node -e "const net=require(process.argv[3]); const socket=net.createConnection({host:process.argv[1],port:Number(process.argv[2])},()=>process.exit(0)); socket.setTimeout(3000); socket.on(process.argv[4],()=>process.exit(1)); socket.on(process.argv[5],()=>process.exit(1));" "$host" "$port" net error timeout; do if [ "$attempt" -ge 60 ]; then echo "MySQL did not become reachable at $host:$port"; exit 1; fi; echo "Waiting for MySQL at $host:$port ($attempt/60)"; attempt=$((attempt + 1)); sleep 2; done; exec docker-entrypoint.sh node current/index.js'`
- **Public domain:** Yes

## Documentation

# Deploy and Host Ghost CMS + MySQL on Railway

Run Ghost 6 on Railway with MySQL 8, persistent content storage, persistent database storage, private networking, and a Railway public domain.

## About Hosting Ghost CMS + MySQL on Railway

- `ghost`: official `ghost:6-alpine` image exposed on port `2368`
- `mysql`: official `mysql:8.4` image on Railway private networking
- Persistent Ghost content volume at `/var/lib/ghost/content`
- Persistent MySQL volume at `/var/lib/mysql`
- Generated MySQL application and root passwords
- Ghost configured with Railway's public domain and private MySQL host

## Why Deploy Ghost CMS + MySQL on Railway

The validated local template waits for MySQL before Ghost starts, which prevents first-boot migration failures when the app beats the database online. It also avoids a Railway HTTP healthcheck path because Ghost redirects common public paths to the canonical site URL while Railway healthchecks need a direct `200`.

Current live note: the published `ghost-cms-mysql` marketplace template still needs this reliability fix applied in the Railway template editor. Do not replace it with a new template unless preserving the existing URL and earnings history is no longer required.

## Validation Proof

- Fixed source validation project: `ghost-cms-mysql-fix-20260523`
- Fixed Ghost deployment reached `SUCCESS`
- Final fixed deployment: `5fd6cd70-9abb-4614-9aa4-9f6d62f7cdc2`
- Public Ghost URL returned HTTP `200`
- Temporary validation project and draft were deleted after verification

## Common Use Cases

- Self-hosted blogs and publications
- Editorial sites
- Newsletter-backed Ghost installs
- Membership and audience experiments
- Ghost evaluation environments

## Dependencies for Ghost CMS + MySQL Hosting

Ghost stores content in MySQL and uploaded media/themes on the Ghost content volume. MySQL stays private; only the Ghost web service receives a public domain.

### Deployment Dependencies

- `url`: Railway public Ghost URL
- `database__connection__host`: private MySQL host
- `database__connection__user`: MySQL application user
- `database__connection__password`: generated MySQL application password
- `MYSQL_PASSWORD`: generated MySQL password
- `MYSQL_ROOT_PASSWORD`: generated MySQL root password

## After Deploy

1. Open the Ghost public URL.
2. Complete Ghost's first-admin setup.
3. Add SMTP variables if newsletters or transactional email are needed.
4. Keep Ghost as a single app instance unless storage, sessions, and queueing are redesigned for horizontal scale.

## Support Checklist

If a deploy fails, include the `ghost` and `mysql` deployment IDs, the first 80 lines of `ghost` logs, and whether the public URL reaches the Ghost setup page.


## Similar templates

- [Pixelfed](https://railway.com/deploy/OZSdEw) — Explore + Share beautiful photos and videos on the Fediverse
- [Hexo](https://railway.com/deploy/hexo) — Self-hosted Hexo blog with editor, comments, and S3 storage
- [NodeBB](https://railway.com/deploy/nodebb) — Node.js based forum software built for the modern web

Open this page in a browser: https://railway.com/deploy/ghost-cms-mysql
