Self-host Dify on Railway for LLM apps and RAG chatbots
Short answer: deploy a Dify template on Railway and open its gateway URL. Tracklayer’s Dify template runs the complete Dify 1.17 stack, including the console, API, workers, plugin daemon, code sandbox, Postgres, Redis and the Weaviate vector store, as fifteen services behind one HTTPS domain. Secrets are generated at deploy, so no input is required.
Deploy Dify on RailwayWhat Dify is for
Dify is an open-source platform for building LLM applications. You design chatbots, RAG knowledge bases, agents and multi-step workflows in a visual editor and publish them as web apps or APIs. Typical uses named in the template:
- internal knowledge assistants that answer from your PDFs, wikis and policies, with citations,
- customer-facing chatbots and embeddable chat widgets backed by any LLM provider,
- multi-step workflows such as classification, extraction or summarisation, exposed as an API,
- tool-using agents that call APIs and run code in a sandbox,
- a shared workspace where a team builds and publishes AI apps without writing backend code.
Why a single container is not enough
Self-hosting Dify means running far more than one container. The console talks to a Flask API. Celery workers index documents and run workflows, a beat scheduler fires timed jobs, a plugin daemon installs and runs plugins, and a code sandbox executes user code. Postgres stores metadata, Redis carries queues and locks, Weaviate holds embeddings, and uploaded files need object storage. A template wires all of that together.
Which AI app builder templates people deploy on Railway
| Template | Creator | Deployments | Services |
|---|---|---|---|
| flowise-railway | Henry Heng's Projects | 8,512 | 1 |
| Langflow | – | 2,852 | 2 |
| flowise-with-n8n-ai-automation | derekcheungsa's Projects | 1,974 | 3 |
| AnythingLLM | Timothy Carambat's Projects | 1,972 | 1 |
| Dify | Jack | 1,871 | 11 |
| Langflow | alphasec | 1,284 | 2 |
| FlowiseAI | Protemplate | 782 | 2 |
| Langflow Pre-releases | – | 358 | 2 |
Railway marketplace data as of 2026-11-19. Full ranking: Best AI app builder templates on Railway.
Dify, Flowise, Langflow and similar tools overlap but differ in scope. Check each template page for the services it deploys and whether it pins versions.
Deploy Dify on Railway, step by step
These steps use Tracklayer’s Dify 1.17 AI App Studio template.
- Deploy the template. Nothing needs to be entered. It creates the Gateway (the only public service), Web, API, API WebSocket, Worker, Worker Beat, Plugin Daemon, Sandbox, two SSRF proxies, Agent Backend, Agent Sandbox, Weaviate, Postgres, Redis and a Railway Bucket.
- Wait for the API to finish migrating. The first boot takes 1 to 3 minutes. Watch the API logs.
- Open the install page. Go to the Gateway URL plus
/install. Dify asks for an init password: copyINIT_PASSWORDfrom the API service variables. - Create the owner account. Then add a model provider under Settings, Model Provider. This installs a plugin from the Dify marketplace.
- Optional: custom domain. Add it to the Gateway service, set
DIFY_PUBLIC_URLon API tohttps://your.domainandNEXT_PUBLIC_SOCKET_URLon Web towss://your.domain, then redeploy. - Optional: email. Set
MAIL_TYPE(smtporresend),MAIL_DEFAULT_SEND_FROMand the matching variables on API, Worker and Worker Beat to enable invitations and password resets.
What is stored where
Postgres, Redis, Weaviate, the plugin daemon, the code sandbox and the agent sandbox each use a volume. Uploaded files and generated assets go to a Railway Bucket. Two Squid proxies filter outgoing requests so the sandboxes cannot reach private networks. Back up Postgres and the Weaviate volume before major upgrades.
Costs
Railway bills usage, and fifteen services in one project means memory across the services is the main cost driver. The Worker and Plugin Daemon grow under load, and each running plugin adds roughly 100 to 150 MB.
The template’s own resource table gives about 2.2 GB of RAM idle and about 5.1 GB under typical team use, with about 7.3 GB of volume. At Railway’s unit prices that is roughly $26 per month idle and $64 per month typical, plus about $0.15 per month for 10 GB of uploads in the Bucket.
These are estimates from upstream defaults and typical footprints, not measurements on Railway. The template lists Hobby as the minimum plan and recommends Pro for teams.
Scaling and upgrades
- To handle more load, add replicas to the stateless Worker or raise
CELERY_WORKER_AMOUNT. Keep Worker Beat at one replica. - Every image is pinned. To upgrade, read the Dify release notes, change all
1.17.1tags together, and update the Plugin Daemon, Sandbox and Weaviate tags to match that release. The API applies database migrations on start.
Limitations and licence
Dify is distributed under the Dify Open Source License, which is Apache 2.0 with additional conditions. Running it for your own organisation is permitted. Operating it as a multi-tenant service for third parties, or removing the logo and copyright from the console, requires a commercial licence from LangGenius. This is a community template and is not affiliated with LangGenius.
Other options
See the full ranking of AI app builder templates on Railway. If you only need a chat interface rather than an app builder, see ChatGPT-style UIs on Railway. For all guides, see /guides/.
FAQ
How do I log in to Dify the first time?
Wait for the API logs to show the migrations finished, which takes 1 to 3 minutes on first boot. Open the Gateway URL at /install, enter INIT_PASSWORD from the API service variables, then create the owner account. Add a model provider under Settings, Model Provider.
Is my data kept across redeploys?
Yes. Postgres, Redis, Weaviate, the plugin daemon, the code sandbox and the agent sandbox use volumes, and uploaded files go to a Railway Bucket.
How much does it cost to run Dify on Railway?
The template's own estimate is about $26 per month idle and about $64 per month for typical team use, plus a small Bucket charge. These are estimates from upstream defaults and typical footprints, not measurements, so check your own usage after deploying. The minimum plan is Hobby.
Can I use Dify commercially if I self-host it?
Dify uses the Dify Open Source License, which is Apache 2.0 with additional conditions. Running it for your own organisation is permitted. Operating it as a multi-tenant service for third parties, or removing the console logo and copyright, requires a commercial licence from LangGenius. Ask a lawyer if your use is customer-facing.