---
title: "Deploy Discourse | (Just Updated) Forum Software, Community Platform With Admin Login And API Key Generated"
description: "Discourse self-hosted forum, community discussion software, Postgres"
category: "Other"
url: https://railway.com/deploy/discourse-or-just-updated-forum-software
---

# Deploy Discourse | (Just Updated) Forum Software, Community Platform With Admin Login And API Key Generated

Discourse self-hosted forum, community discussion software, Postgres

**[Deploy Discourse | (Just Updated) Forum Software, Community Platform With Admin Login And API Key Generated on Railway](https://railway.com/template/discourse-or-just-updated-forum-software)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/discourse-or-just-updated-forum-software/manifest.json

- **Creator:** SuperSlowSloth
- **Category:** Other

## Template content

### cache

- **Image:** redis:8.2.1-alpine@sha256:987c376c727652f99625c7d205a1cba3cb2c53b92b0b62aade2bd48ee1593232
- **Start command:** `/bin/sh -c 'chown -R redis:redis /data && exec docker-entrypoint.sh redis-server --requirepass "$REDIS_PASSWORD" --appendonly yes --maxmemory-policy noeviction --dir /data'`

### discourse

- **Image:** ghcr.io/bon5co/discourse-railway:2026.11.0-latest.2@sha256:7d6ac13fdd985c07f2cca9c3295f4ed6157a015ec5a486625ae95c17ac0da95e
- **Public domain:** Yes

### database

- **Image:** pgvector/pgvector@sha256:78bf48b801e792f99e3ac62b5036fd3876e9be48afda16c1e331af1c75ceb2ff

## Documentation

# Deploy and Host Discourse on Railway

**Built for an LLM agent to deploy and use.** The deploy form has no fields to fill: the administrator login, an admin API key, the application secret and the database and Redis passwords are generated, the server cannot start without them, and the administrator exists with sign-up closed before the first visitor arrives, so nobody can claim the forum through the open setup wizard or register uninvited. Discourse is the open-source forum and community discussion platform: categories and tags, trust levels, moderation tools, chat, plugins and a full admin REST API.

## About Hosting Discourse

This template runs three services: **discourse**, the official Discourse image (2026.11.0-latest.2) pinned by digest through a thin wrapper, with a volume at `/shared` that holds uploads and backups; **database**, a PostgreSQL 18 instance with the pgvector extension and a volume at `/var/lib/postgresql` that holds topics, posts, users and search indexes; and **cache**, a Redis 8 instance with a volume at `/data` that holds the job queue and message bus. One public domain serves the forum and its API. The stock image runs nginx, the Rails app and the background job worker in one container and listens on port 80, which Railway's healthcheck and edge do not dial; the wrapper moves nginx onto the injected `PORT` (8080), and `GET /srv/status` answers 200 once the app is up. A cold first boot runs the database migrations and compiles assets, so allow several minutes before the first request answers.

**What the wrapper fixes.** The official image has no way to create the first administrator without a person at a terminal or in the setup wizard, and until someone does, sign-up is open to the first visitor. The wrapper creates the administrator from `ADMIN_EMAIL` and `ADMIN_PASSWORD` and an API key from `ADMIN_API_KEY` as soon as the app answers, turns off registration and makes the forum invite-only, and refuses anonymous POSTs to the account-creation routes at the nginx layer, because Discourse itself answers those with HTTP 200 and a decoy "activation mail sent" body meant for bots. Railway mounts volumes owned by root, so the wrapper hands `/shared` to Discourse's user. It refuses to start without a login password of at least 12 characters, a 32-character API key, and database and Redis credentials. The database is pgvector rather than plain Postgres because Discourse's AI plugin migration enables the `vector` extension and fails without it. Checked on a Railway deploy: the API key reads and writes, a write without it answers 403, and an anonymous sign-up answers 403. Not reproduced on a Railway control of an incumbent listing.

**Using it.** Open the domain and sign in as `ADMIN_EMAIL` with `ADMIN_PASSWORD` (username `admin`). Outgoing email is not configured: add `DISCOURSE_SMTP_ADDRESS`, `DISCOURSE_SMTP_PORT`, `DISCOURSE_SMTP_USER_NAME` and `DISCOURSE_SMTP_PASSWORD` variables on the `discourse` service to send notifications and invitations. Everything is stored in PostgreSQL, Redis and the `/shared` volume, so redeploys keep it.

### Agent contract

- Public URL: `https://RAILWAY_PUBLIC_DOMAIN` (the generated domain of the `discourse` service)
- Private URL: `http://discourse.railway.internal:8080`
- Credentials: the variables `ADMIN_EMAIL`, `ADMIN_PASSWORD` and `ADMIN_API_KEY` on the `discourse` service (plain text; `ADMIN_EMAIL` is `admin@` plus the public domain, the username is `admin`)
- Auth: send the headers `Api-Key: $ADMIN_API_KEY` and `Api-Username: admin` on every API call; the web login uses `ADMIN_EMAIL` and `ADMIN_PASSWORD`
- Health: `GET /srv/status` returns 200 without credentials

```bash
#!/bin/sh
# needs: RAILWAY_PUBLIC_DOMAIN, ADMIN_API_KEY (variables of the discourse service); also curl.
R="https://$RAILWAY_PUBLIC_DOMAIN"; A="Api-Key: $ADMIN_API_KEY"; U="Api-Username: admin"
n=0; until [ "$(curl -s -o /dev/null -w '%{http_code}' "$R/srv/status")" = 200 ]; do n=$((n+1)); [ "$n" -le 240 ] || break; sleep 5; done
curl -s -o /dev/null -w "health: %{http_code}\n" "$R/srv/status"
# the administrator and its API key are created once the app answers; wait until the key is accepted
n=0; until [ "$(curl -s -o /dev/null -w '%{http_code}' -H "$A" -H "$U" "$R/admin/users/list/active.json")" = 200 ]; do n=$((n+1)); [ "$n" -le 60 ] || break; sleep 5; done
curl -s -o /dev/null -w "read with key: %{http_code}\n" -H "$A" -H "$U" "$R/admin/users/list/active.json"
# write-auth: creating a category with the key succeeds, the same call with no credential is refused
curl -s -o /dev/null -w "write with key: %{http_code}\n" -H "$A" -H "$U" -d "name=Agent check $$" -d color=0088CC -d text_color=FFFFFF "$R/categories.json"
curl -s -o /dev/null -w "write without key: %{http_code}\n" -d "name=Anon $$" -d color=0088CC -d text_color=FFFFFF "$R/categories.json"
# signup: an anonymous account-creation POST is refused at the edge (Discourse itself would answer 200 with a decoy body)
curl -s -o /dev/null -w "public signup: %{http_code}\n" -d name=Stranger -d email=stranger@example.org -d username=stranger -d "password=Str4ngerLogin123" "$R/users.json"
```

Expected output against a fresh deploy (measured on the Railway demo; the output is recorded in `template.md`):

```text
health: 200
read with key: 200
write with key: 200
write without key: 403
public signup: 403
```

The refusals are the contract: a write without the key answers 403 (`write without key: 403`), and an anonymous account-creation POST answers 403 (`public signup: 403`). A request that carries the admin API key can still create users through `POST /users.json`.

## Why Deploy Discourse on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Discourse on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.

- **Agent-ready** - no deployer fields, a contract block, and one script that proves the server is healthy, a stranger is refused, and the generated API key can read and write.
- **Locked from the first request** - the administrator exists at boot, registration is off and the forum is invite-only, so the setup wizard never serves a visitor.
- **Data survives redeploys** - topics in PostgreSQL on a volume, the job queue in Redis on a volume, uploads on a volume.
- **Migrations run** - the wrapper enables migrate-on-boot, so a newer image upgrades the schema on redeploy.
- **Pinned** - the upstream image is pinned by digest and the wrapper by tag and digest.

## Common Use Cases

- **Community forum** - host a public or invite-only discussion board for a product, game or open-source project.
- **Customer support and knowledge base** - answer questions in categories, with search, tags and accepted answers.
- **Internal discussion board** - keep team threads, announcements and decisions on infrastructure you control.

## Dependencies for Discourse Hosting

- The discourse service, a PostgreSQL service with pgvector and a Redis service, each with its volume, created by the template.

### Deployment Dependencies

- [Discourse repository](https://github.com/discourse/discourse)
- [Discourse website](https://www.discourse.org)
- [Wrapper image source](https://github.com/bon5co/discourse-railway)


## Similar templates

- [Rocky Linux](https://railway.com/deploy/rocky-linux) — Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀
- [Foundry Virtual Tabletop](https://railway.com/deploy/X5tR6G) — Self-hosted virtual tabletop for role-playing games (license required)
- [Double Commander in your browser](https://railway.com/deploy/double-commander-in-your-browser) — The Double Commander file manager in the cloud, from any device

Open this page in a browser: https://railway.com/deploy/discourse-or-just-updated-forum-software
