Self-host Langfuse on Railway for LLM tracing and cost
Short answer: to see what your AI app’s LLM calls cost and do without sending data to another SaaS, self-host Langfuse. It records each call as a trace with latency, token usage and cost, and adds a prompt registry, datasets and evaluations. The Tracklayer template deploys the full Langfuse v4 stack on Railway (web, worker, ClickHouse, Postgres, Redis and a bucket) and creates the first admin, project and API keys for you.
Deploy Langfuse on RailwayWhen this makes sense
Provider dashboards show total spend, but not which feature, user or prompt version caused it. A tracing tool fills that gap. Self-hosting it makes sense when prompts and completions contain data you do not want to leave your own infrastructure, for example for data-residency or compliance reasons.
With Langfuse you can:
- trace LLM calls, tool calls and agent steps, with latency, token usage and cost per request,
- keep prompts in a central registry and compare versions with datasets and experiments,
- score answers with LLM-as-a-judge or human annotation,
- act as the observability backend for an LLM gateway such as LiteLLM.
Observability templates people deploy on Railway
| Template | Creator | Deployments | Services |
|---|---|---|---|
| Uptime Kuma | Brody's Projects | 1,456 | 1 |
| Langfuse v3 | Langfuse's Projects | 688 | 6 |
| Grafana 13 LGTM Observability Stack | Tracklayer | 10 | 5 |
| SigNoz APM for Railway Apps | Tracklayer | 3 | 5 |
| Helicone LLM Observability Gateway | Tracklayer | 2 | 7 |
| Langfuse v4 LLM Observability Stack | Tracklayer | 2 | 5 |
Railway marketplace data as of 2026-11-19. Full ranking: Best observability and monitoring templates on Railway.
The list mixes general monitoring tools with LLM-specific ones. If you only need to watch LLM calls, look for templates named after an LLM observability tool and check their services before deploying.
Deploy Langfuse, step by step
These steps use Tracklayer’s Langfuse v4 LLM Observability Stack template.
- Use the Hobby or Pro plan.
langfuse-webneeds at least 1.5 GB of memory, so Railway’s Trial and Free plans cannot run it. - Deploy the template and enter your email.
LANGFUSE_INIT_USER_EMAILis the only required input. The template createslangfuse-web,langfuse-worker, ClickHouse, Postgres, Redis and a Railway Bucket. - Wait for
langfuse-webto become healthy. The first start runs database migrations and can take several minutes. - Sign in. Open the web domain and use your email with the generated
LANGFUSE_INIT_USER_PASSWORDfrom thelangfuse-webvariables. Change the password in your profile. - Copy your project keys.
LANGFUSE_INIT_PROJECT_PUBLIC_KEYandLANGFUSE_INIT_PROJECT_SECRET_KEYare generated for the first project. Keep the secret key private.
Public sign-up is off by default (AUTH_DISABLE_SIGNUP=true). To let teammates create accounts, set it to false, invite them, then switch it back.
How your app sends traces
Per the template documentation, the web service accepts traces from the Langfuse SDKs, from OpenTelemetry and from integrations such as LiteLLM. In your app:
- Use the Langfuse SDK (v4 SDKs are supported) with the public key, the secret key and
LANGFUSE_HOST=https://<your-web-domain>. - Or send OpenTelemetry data to the
/api/public/otelendpoint. - Note that the older
/api/public/ingestionendpoint only takes scores in v4.
Web stores each raw event in the bucket and queues a job in Redis. The worker then writes traces, observations and scores to ClickHouse, which powers the trace explorer and dashboards. Expect a short delay between a call and its trace appearing.
Storage and persistence
ClickHouse holds traces, Postgres holds users, projects, prompts and keys, and Redis holds queues and cache. Each has a volume. Raw events, media and batch exports go to the Railway Bucket. Only langfuse-web is public; the rest talk over Railway’s private network.
What it costs
The template does not state a monthly price, and this guide does not either. Railway bills usage, so cost follows memory and CPU across five services, plus volumes and bucket storage. In the template author’s tests, langfuse-web held about 720 MB of live heap right after start and crash-looped at roughly 714 MiB, which is why it needs at least 1.5 GB. ClickHouse is the other main memory consumer as the volume of traces grows. Both langfuse-web and langfuse-worker are stateless and can be given more replicas; ClickHouse scales by adding RAM and CPU.
Limitations and licence notes
- Licence. According to the template’s NOTICE.md, the Langfuse core is MIT-licensed. Code under
ee/,web/src/ee/andworker/src/ee/falls under the Langfuse enterprise license and is not enabled by this template. Check Langfuse’s documentation for which features that covers, and consult a lawyer if licensing matters for your business. - Telemetry.
TELEMETRY_ENABLEDistrueby default and sends anonymous usage data to Langfuse. Set it tofalseto opt out. - Keys.
SALTandENCRYPTION_KEYare generated once and must never be changed after first deploy. Save them somewhere safe. - Upgrades. Always upgrade web and worker to the same version together.
- Community template. It is not affiliated with or endorsed by Langfuse or ClickHouse, Inc.
Other options
- Helicone v2025.08 is a different LLM observability tool: you point your OpenAI or Anthropic client at its proxy and requests are logged with cost, latency and tokens. It deploys ClickHouse, Postgres and S3-compatible storage.
- New API is an LLM gateway rather than a tracing tool. It puts several providers behind compatible APIs with users, tokens, quotas and usage logs, and runs with Postgres and Redis. It is useful if you want usage tracking and quotas at the gateway.
For more choices, see the full ranking of observability templates on Railway, or browse all guides.
FAQ
Can I use Langfuse for free if I self-host it?
The Langfuse core is MIT-licensed, and this template runs only that core. Code under Langfuse's ee/ folders is covered by a separate enterprise license and is not enabled by the template. Hosting costs on Railway still apply. Check Langfuse's own documentation for which features need a paid license.
Why does Langfuse fail to start on Railway's Trial or Free plan?
The web service needs at least 1.5 GB of memory. Railway's Trial plan gives 1 GB per service and Free gives 0.5 GB, so web stops with a JavaScript heap out of memory error. The template README says to use the Hobby or Pro plan.
Where do I find the login and the API keys?
Open the langfuse-web service on Railway and go to Variables. Sign in with the email you entered at deploy time and LANGFUSE_INIT_USER_PASSWORD. The SDK keys are LANGFUSE_INIT_PROJECT_PUBLIC_KEY and LANGFUSE_INIT_PROJECT_SECRET_KEY.
Is my trace data kept when I redeploy?
Yes. ClickHouse, Postgres and Redis each use a volume, and raw events, media and exports go to a Railway Bucket. Back up these stores yourself; the template does not describe a backup job.
How do I upgrade Langfuse?
Web and worker are pinned to the same version (4.56.0 at the time of writing). Change the tag on both, read the Langfuse changelog for breaking changes, then redeploy. Migrations run automatically when web starts.