Deploy Lemmy
Link aggregator and discussion forum that talks to the fediverse
Just deployed
lemmy-ui
Just deployed
Just deployed
/var/lib/postgresql/data
pictrs
Just deployed
/mnt
Just deployed
mailpit
Just deployed
/data
Deploy and Host Lemmy on Railway
Lemmy is an open-source link aggregator and discussion platform — communities, threaded comments and voting in the shape people know from Reddit, except every instance federates over ActivityPub. Someone on Mastodon, Mbin or another Lemmy server can subscribe, comment and vote without an account on yours, while you keep the moderation rules, the data and the domain.
Deploy Lemmy on Railway and the whole stack comes up wired together: the Rust API server, the web UI, a Caddy front door routing browser and ActivityPub traffic to the right place, pict-rs for image uploads on a volume, PostgreSQL, and a mail catcher so password resets work on day one. Self-host Lemmy without writing an nginx config or an hjson settings file — the source repository gridalpha/lemmy-railway renders that config from environment variables at boot.

Getting Started with Lemmy on Railway
Open the proxy service's public URL once the deploy finishes. There is no installation wizard: setup has already run, and an administrator exists with the username from LEMMY_SETUP_ADMIN_USERNAME (default admin) and the password you gave as LEMMY_SETUP_ADMIN_PASSWORD. Sign in at /login, then open Create Community — the URL name becomes its federated address, !name@your-domain, and cannot be changed later.
Post something to confirm the stack is live: use the create-post screen's image field rather than pasting a link, because that upload travels through the proxy to pict-rs and back, so a thumbnail on the front page proves the image tier and its volume both work. Visit /admin for the site description, sidebar and rate limits; new sign-ups land under Registration Applications. To federate, search for a remote community as !community@instance.tld.



About Hosting Lemmy
Lemmy solves a problem centralised forums cannot: a community that outlives the platform it started on. Every user, community and post is an addressable ActivityPub object, so people on other servers take part as first-class members.
- Communities with threaded comments, voting, sorting and full-text search
- Federation with Lemmy, Mbin, PieFed, Mastodon and anything on ActivityPub
- Moderation: registration applications, reports, bans, a public modlog
- Image uploads, remote thumbnail caching and an optional image proxy
- A documented
/api/v3REST API behind Jerboa, Voyager and Thunder
The architecture mirrors upstream's production layout. lemmy is the Rust API server: it owns the schema, runs migrations at boot and drives the federation queue in-process. lemmy-ui server-renders the web app and calls the API privately. proxy cannot be skipped — an ActivityPub fetch of /u/name is the same URL a browser requests, distinguished only by the Accept header, so Caddy sends API paths, inbox POSTs and ActivityPub requests to the backend and everything else to the UI. pictrs keeps originals and thumbnails on a volume, Postgres holds every post, comment, vote and remote actor, and mailpit captures mail until a real relay is connected.
Why Deploy Lemmy on Railway
The multi-service part of running a fediverse instance is already done.
- Six services deploy together, already networked and referenced
- Managed PostgreSQL with backups, no tuning
- Persistent volumes for uploaded images and captured mail
- Managed TLS and custom domains
- Git redeploys, per-service logs and metrics
Common Use Cases
- A topic community that federates with the wider Lemmy network instead of starting from zero
- A private space for a company, club or user group, closed behind sign-up approval
- A moderated forum on your own domain, where you set the rules
- A backend for a fediverse client or bot, driven through
/api/v3
Dependencies for Lemmy
- lemmy —
dessalines/lemmy:0.19.20, built from gridalpha/lemmy-railway so its hjson config is generated from environment variables - lemmy-ui —
dessalines/lemmy-ui:0.19.20, the official web client, pinned to match the backend - proxy —
caddy:2-alpine, splitting one public origin between the API and the UI - pictrs —
asonix/pictrs:0.5, image storage and processing, volume at/mnt - Postgres — Railway managed PostgreSQL 18, the single source of truth
- mailpit —
axllent/mailpit:latest, capture-only SMTP on 1025, inbox on 8025
Environment Variables Reference
| Variable | Description | Required |
|---|---|---|
LEMMY_HOSTNAME | Public domain; written into every federated URL at first setup, effectively permanent | Yes |
LEMMY_SETUP_ADMIN_USERNAME | First administrator's username | Yes |
LEMMY_SETUP_ADMIN_PASSWORD | First administrator's password, 10–60 characters | Yes |
LEMMY_SETUP_SITE_NAME | Instance name, 20 characters maximum | Yes |
LEMMY_PICTRS_API_KEY | Shared with pict-rs; needed to delete uploaded images | Yes |
LEMMY_PICTRS_IMAGE_MODE | None, StoreLinkPreviews or ProxyAllImages | No |
LEMMY_TLS_ENABLED | Must stay true — federation requires HTTPS URLs | Yes |
LEMMY_SMTP_SERVER | SMTP host and port; unset to disable outgoing mail | No |
MP_UI_AUTH | user:password guarding the Mailpit inbox | Yes |
Deployment Dependencies
- Source: LemmyNet/lemmy, LemmyNet/lemmy-ui
- Images: dessalines/lemmy, asonix/pictrs
- Docs: join-lemmy.org/docs
- PostgreSQL 12+; the backend and the UI must run the same release
Server Requirements to Self-Host Lemmy
| Resource | Minimum | Recommended |
|---|---|---|
| CPU | 1 vCPU | 2 vCPU |
| RAM | 2 GB total | 4 GB |
| Storage | 5 GB images + 5 GB PostgreSQL | 20 GB+ once federating widely |
| PostgreSQL | 12+ | 16+ |
The Rust backend is small — a few hundred megabytes at rest. Growth comes from federation: subscribing to busy remote communities pulls in their posts, comments and cached thumbnails, so size storage by how much of the network you follow, not by local user count. LEMMY_PICTRS_IMAGE_MODE=None keeps remote thumbnails off the volume.
How to Self-Host Lemmy Outside Railway
Lemmy's own compose file is the fastest route on a VPS, with a proxy in front because the routing rules are part of the app:
git clone https://github.com/LemmyNet/lemmy
cd lemmy/docker
cp lemmy.hjson.example lemmy.hjson # set hostname, database and pictrs
docker compose up -d
The image server also runs standalone while you test:
docker run -d --name pictrs -p 8080:8080 \
-v ./pictrs:/mnt \
-e PICTRS__SERVER__ADDRESS=0.0.0.0:8080 \
asonix/pictrs:0.5
Route /api, /pictrs, /feeds, /nodeinfo, /.well-known and any request whose Accept header contains application/activity+json to the backend, everything else to the UI. Get TLS working before first boot: the hostname is baked into federated URLs.
Is Lemmy Free?
Lemmy is free and open source under AGPL-3.0. There is no paid tier, licence key or hosted commercial edition; the project runs on donations. On Railway you pay only for the compute, storage and bandwidth the six services use. Federating with many large communities is what moves the bill, mostly through image storage and database growth.
FAQ
What is Lemmy? An open-source link aggregator and discussion platform, similar in shape to Reddit, where every instance federates with the rest of the fediverse over ActivityPub. Users on other servers can subscribe, post and comment without an account on yours.
What does this Railway template deploy? Six services: the Lemmy API server, the web UI, a Caddy front door, pict-rs for image hosting on a volume, managed PostgreSQL, and a Mailpit inbox for outgoing mail.
Why does the template include a proxy service?
Lemmy serves one public origin from two applications, and the split depends on the request's Accept header, not just its path: a federating server asking for /u/alice must reach the API while a browser asking for the same URL must reach the web UI.
Why is PostgreSQL required? It stores everything: users, communities, posts, comments, votes, and the cached remote actors federation pulls in. Lemmy migrates it at startup.
Can I change my instance's domain later? Not safely. The hostname goes into every user, community and post URL at first setup, and remote servers record those addresses. Choose the domain — custom domain included — before first boot.
How do I stop strangers from signing up?
Registrations default to requiring administrator approval, with pending requests under Registration Applications in /admin. Open sign-ups, email verification and closed registration are options on the same screen.
Does self-hosted Lemmy have an API for mobile apps?
Yes. The REST API at /api/v3 is what Jerboa, Voyager and Thunder speak, so pointing any of them at your domain works immediately.
Template Content
