Railway

Deploy Lemmy

Link aggregator and discussion forum that talks to the fediverse

Deploy Lemmy

Just deployed

Just deployed

/var/lib/postgresql/data

Just deployed

/mnt

Just deployed

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.

Lemmy's six Railway services and the links between them

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.

Lemmy front page listing two posts in a community

A Lemmy post with an uploaded image and one comment

Lemmy admin reviewing a pending registration application

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/v3 REST 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

  • lemmydessalines/lemmy:0.19.20, built from gridalpha/lemmy-railway so its hjson config is generated from environment variables
  • lemmy-uidessalines/lemmy-ui:0.19.20, the official web client, pinned to match the backend
  • proxycaddy:2-alpine, splitting one public origin between the API and the UI
  • pictrsasonix/pictrs:0.5, image storage and processing, volume at /mnt
  • Postgres — Railway managed PostgreSQL 18, the single source of truth
  • mailpitaxllent/mailpit:latest, capture-only SMTP on 1025, inbox on 8025

Environment Variables Reference

VariableDescriptionRequired
LEMMY_HOSTNAMEPublic domain; written into every federated URL at first setup, effectively permanentYes
LEMMY_SETUP_ADMIN_USERNAMEFirst administrator's usernameYes
LEMMY_SETUP_ADMIN_PASSWORDFirst administrator's password, 10–60 charactersYes
LEMMY_SETUP_SITE_NAMEInstance name, 20 characters maximumYes
LEMMY_PICTRS_API_KEYShared with pict-rs; needed to delete uploaded imagesYes
LEMMY_PICTRS_IMAGE_MODENone, StoreLinkPreviews or ProxyAllImagesNo
LEMMY_TLS_ENABLEDMust stay true — federation requires HTTPS URLsYes
LEMMY_SMTP_SERVERSMTP host and port; unset to disable outgoing mailNo
MP_UI_AUTHuser:password guarding the Mailpit inboxYes

Deployment Dependencies

Server Requirements to Self-Host Lemmy

ResourceMinimumRecommended
CPU1 vCPU2 vCPU
RAM2 GB total4 GB
Storage5 GB images + 5 GB PostgreSQL20 GB+ once federating widely
PostgreSQL12+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

More templates in this category

View Template
Rocky Linux
Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀

codestorm
44
View Template
Foundry Virtual Tabletop
A Self-Hosted & Modern Roleplaying Platform

Lucas
71
View Template
Letta Code Remote
Run a Letta Code agent 24/7. No inbound ports, just deploy.

Letta
51