Self-host Langfuse on Railway for LLM tracing and cost

By Tracklayer · Updated 2026-11-20

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 Railway

When 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:

Observability templates people deploy on Railway

TemplateCreatorDeploymentsServices
Uptime KumaBrody's Projects1,4561
Langfuse v3Langfuse's Projects6886
Grafana 13 LGTM Observability StackTracklayer105
SigNoz APM for Railway AppsTracklayer35
Helicone LLM Observability GatewayTracklayer27
Langfuse v4 LLM Observability StackTracklayer25

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.

  1. Use the Hobby or Pro plan. langfuse-web needs at least 1.5 GB of memory, so Railway’s Trial and Free plans cannot run it.
  2. Deploy the template and enter your email. LANGFUSE_INIT_USER_EMAIL is the only required input. The template creates langfuse-web, langfuse-worker, ClickHouse, Postgres, Redis and a Railway Bucket.
  3. Wait for langfuse-web to become healthy. The first start runs database migrations and can take several minutes.
  4. Sign in. Open the web domain and use your email with the generated LANGFUSE_INIT_USER_PASSWORD from the langfuse-web variables. Change the password in your profile.
  5. Copy your project keys. LANGFUSE_INIT_PROJECT_PUBLIC_KEY and LANGFUSE_INIT_PROJECT_SECRET_KEY are 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:

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

Other options

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.