Deploy CTFd
Capture-the-flag platform with MariaDB, Redis, volumes and locked setup
MariaDB
Just deployed
/var/lib/mysql
Redis
Just deployed
/data
CTFd
Just deployed
/data
Deploy and Host CTFd on Railway
CTFd is an open-source platform for running capture-the-flag (CTF) competitions. Admins create challenges with flags, hints and downloadable files. Players or teams register, submit flags and climb a live scoreboard. It includes user and team modes, dynamic scoring, an admin panel, plugins and themes, and a REST API.
About Hosting CTFd
Hosting CTFd means running its Python (gunicorn) web app with a MySQL-compatible database, a Redis cache, and persistent storage for challenge files. This template deploys the official ctfd/ctfd 3.8.9 image with MariaDB 10.11 and Redis 8.8, each pinned by digest and on its own volume, so challenges, users, solves and uploads survive redeploys. CTFd runs three gevent workers behind Railway's proxy with the real client IP passed through. It connects to the database and cache over the private network, and generates its secret key at deploy time. The first-run setup wizard is locked behind a generated SETUP_TOKEN, so nobody else can claim the admin account before you do.
Common Use Cases
- Running a public or private CTF competition for a conference, meetup or online event
- Security training and workshops in schools, universities and companies
- Hosting an internal practice range of challenges for a red team or a CTF team
Dependencies for CTFd Hosting
- MariaDB (database for users, challenges, submissions and settings)
- Redis (cache and session store)
Deployment Dependencies
- CTFd on GitHub and the 3.8.9 release
- CTFd deployment docs and configuration reference
- Images: ctfd/ctfd, mariadb, redis
Implementation Details
After the deploy finishes, open the CTFd service's Variables tab in Railway, copy SETUP_TOKEN, and visit:
https:///setup?token=
Complete the wizard to name your event and create the admin account. Until then, every page shows a short "setup is locked" notice. Once setup is done, the token has no further effect.
- Uploads and CTFd's logs live on the CTFd volume at
/data. MariaDB stores its data on its own volume, and Redis on another. - Defaults are set in the start command and can be overridden with service variables:
WORKERS(3),WORKER_CLASS(gevent),REVERSE_PROXY(2,1,1,1,0),UPLOAD_FOLDER,LOG_FOLDER. Any other CTFd setting, such asMAIL_SERVERfor email, can be added as a variable. - The container starts as root only to fix the volume's ownership, then drops to CTFd's own user (uid 1001).
Why Deploy CTFd 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 CTFd 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.
Template Content

