Self-host PostHog on Railway: what it needs and costs
Short answer: yes, you can self-host PostHog on Railway, but it is a large deployment. PostHog’s self-hosted stack is a distributed system, and the Tracklayer template runs it as 23 Railway services behind one public router. Expect to need a Hobby plan at minimum, Pro for real use, and around 10 GB of RAM at idle. If you only need page views and referrers, a smaller tool is a better fit.
Deploy PostHog on RailwayWhen this makes sense
PostHog is an open-source product platform. Per the template documentation, self-hosting gives you:
- product analytics: funnels, retention, paths, cohorts and SQL insights over raw events,
- session replay and heatmaps, with recordings stored in your project,
- feature flags and A/B experiments evaluated by your own flag service,
- web analytics, surveys, error tracking and LLM analytics next to the same data.
Self-hosting suits teams that want that data in their own project and can pay for the memory. It is more than most small sites need.
What the template deploys
The stack follows PostHog’s own self-hosted (“hobby”) compose files, built from PostHog’s images. Only one service is public.
| Group | What runs |
|---|---|
| Edge | proxy, the single public service, which routes to everything else |
| App | web (Django UI and API), worker (Celery and scheduler), a Temporal worker |
| Ingestion | Node services for events, replay, error tracking and data pipelines |
| Capture and flags | Rust and Go services for SDK endpoints, feature flags, persons, error symbolication and live events |
| Data | ClickHouse, ZooKeeper, Redpanda (Kafka API), Postgres, Redis, SeaweedFS |
| Jobs | Temporal, and Browserless for image exports |
ClickHouse, Redpanda, Postgres, SeaweedFS and ZooKeeper have volumes. SeaweedFS holds session recordings and exports.
Analytics templates people deploy on Railway
| Template | Creator | Deployments | Services |
|---|---|---|---|
| Umami | Brody's Projects | 4,236 | 3 |
| Metabase | Brody's Projects | 2,642 | 2 |
| Plausible Analytics | Tinybox Software | 915 | 3 |
| Langfuse v3 | Langfuse's Projects | 688 | 6 |
| Elasticsearch | Lasso Moderation | 264 | 1 |
| OmniRoute | A3A | 208 | 1 |
| PostHog Product Analytics Suite | Tracklayer | 14 | 23 |
| Plausible v3 Privacy-First Analytics | Tracklayer | 3 | 3 |
Railway marketplace data as of 2026-11-19. Full ranking: Best privacy-friendly web analytics templates on Railway.
The list mixes lightweight analytics tools with PostHog. Compare the number of services before you pick one.
Deploy PostHog, step by step
These steps use Tracklayer’s PostHog Product Analytics Suite template.
- Choose a plan. Hobby is the minimum. Pro is recommended for production because Hobby caps each volume at 5 GB.
- Deploy the template. All secrets are generated for you. Wait until
webis active. Its pre-deploy step runs all migrations, which takes 10 to 20 minutes on the first deploy. - Create your account at once. Open the
proxyservice’s public domain and complete the signup wizard. The first account becomes the instance owner, so do this straight after deploy, then invite teammates from the organization settings. - Add the snippet. Copy the project snippet from Project settings into your site or app. SDKs use
https://<your-proxy-domain>as the API host. - Check GeoIP. The template notes that country data on events needs the GeoIP transformation to exist for your project. Look under Data pipelines, Transformations after first login.
Optional settings on web: ANTHROPIC_API_KEY turns on PostHog AI and OPENAI_API_KEY turns on SQL and regex assist. Invite and password-reset emails need PostHog’s EMAIL_* variables on web and worker, and outbound SMTP needs Railway’s Pro plan. For a custom domain, add it to proxy, then set SITE_URL on web and redeploy the PostHog services.
What it costs
Railway bills usage, and here memory is the main driver. The template’s notes give these figures at Railway’s usage prices:
- Idle: about 10 GB of RAM, roughly $115 a month. This was measured in a local test with all services running and a handful of test events; the Browserless service was not started and is estimated.
- A few million events a month: about 16 to 18 GB, roughly $210 to $230 a month. This is an estimate, not a measurement.
ClickHouse, Redpanda and the web workers are large consumers. The template notes that lowering WEB_CONCURRENCY to 1 saves about 1 GB if you do not need Celery throughput. PostHog itself says its hobby stack needs at least 8 GB of RAM.
Scaling and upgrades
capture, ingestion and recordings are stateless and can run more replicas. Keep worker at one replica because it runs the scheduler. ClickHouse and Redpanda scale by adding memory and CPU.
PostHog publishes no versioned self-hosted releases, so every image is pinned to a commit build. Upgrades are deliberate: update the tags together and diff PostHog’s compose files first.
Limitations and licence notes
- Size. 23 services is a lot to operate. If one process inside a multi-process service stops, the whole service restarts.
- Deploy testing. The template notes describe local verification of the full stack and a first Railway run in which 22 of 23 services were healthy, followed by fixes. Treat your first deploy as something to watch.
- Licences. PostHog is MIT except
ee/. Redpanda core is BUSL-1.1. Browserless is SSPL-1.0 or commercial. Read NOTICE details on the template page and ask a lawyer if you plan commercial or closed-source use. - Community template. It is not affiliated with or endorsed by PostHog Inc.
Other options
If you want simple, cookie-free page-view analytics, these are far smaller:
- Plausible v3 runs Plausible Community Edition with ClickHouse and Postgres.
- Umami v3 runs Umami with Postgres only.
See the privacy-friendly analytics guide for a side-by-side, the full ranking of web analytics templates on Railway, or browse all guides.
FAQ
How do I log in to a new PostHog instance?
Wait until the web service is active; the first deploy runs all migrations and takes 10 to 20 minutes. Open the proxy service's public domain and complete the signup wizard. The first account becomes the instance owner, so do this right away. SDKs use your proxy domain as the API host.
Why does PostHog use so much memory?
Self-hosted PostHog is many processes: Django, Celery, Node ingestion, Rust capture services, ClickHouse, Redpanda, ZooKeeper, Postgres, Redis and more. The template's notes put idle usage at around 10 GB of RAM, measured in a local test, and estimate 16 to 18 GB for a team sending a few million events a month. Grouping processes into fewer services does not reduce the total.
Which Railway plan do I need?
Hobby is the minimum, because Trial's 1 GB per service is too small. Pro is recommended for production, because Hobby limits each volume to 5 GB and ClickHouse and the recordings store outgrow that quickly.
How do I upgrade PostHog?
PostHog does not publish versioned self-hosted releases, so every image is pinned to a commit build. To upgrade, pick a newer commit and update the image tags listed in the template README, then compare PostHog's compose files between the two commits for new services or variables before redeploying.
Which licence notes apply?
PostHog is MIT except the ee/ directory, which uses PostHog's Enterprise licence; paid features stay locked without a key. Redpanda core is BUSL-1.1: free to self-host, not to resell as a streaming service. Browserless is SSPL-1.0 or commercial, and Browserless states that closed-source commercial use needs a commercial licence. You can remove the browserless service; PNG exports and heatmap screenshots then stop working. This is not legal advice.