Deploy n8n AI Agent
self-hosted LangChain AI agents with n8n
Redis
Just deployed
/data
Just deployed
/home/node/.n8n
Just deployed
/var/lib/postgresql/data
n8n-worker
Just deployed
Deploy and Host self hosted n8n AI Agent (Open-Source LangChain Agents) on Railway
n8n AI Agent is a self-hosted LangChain agent host: Chat Trigger, an AI Agent node, a chat model, tools (HTTP Request, Workflow Tool, Calculator, Code), and memory. The editor serves the chat UI; workers run the agent loop so multi-tool turns do not stall the canvas. For a small instance without workers, use the cheapest n8n without queue mode. In queue mode use Postgres Chat Memory, not Simple Memory, so session history survives worker hops.
About Hosting n8n AI Agent open-source software on Railway (self hosted n8n template)
Self hosting n8n AI Agent keeps model credentials, tool secrets, and chat history on your stack. Chat Trigger exposes public HTTPS chat; the AI Agent node reasons with a connected model and tools. The editor takes UI and webhooks; workers pull from Redis and write to Postgres. Railway wires networking, /home/node/.n8n, and HTTPS.
Why Deploy n8n AI Agent, the OpenAI Assistants alternative on Railway (Railway Free Trial)
OpenAI Assistants API meters tokens and tool calls in their cloud; n8n Cloud Starter is about $24/month for 2,500 executions. Self hosted n8n AI Agent on Railway is typically $10-$25/month for editor, worker, Postgres, and Redis with unlimited Community runs. Railway gives a $5 free trial.
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying n8n AI Agent on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Railway vs Other Hosting Providers and VPS for n8n AI Agent self hosting
| Provider | What You Get with Railway | What You Get with the Other Provider |
|---|---|---|
| DigitalOcean | One-click editor, worker, Postgres, Redis, volume, and HTTPS | Droplet, Docker Compose, Nginx, SSL, and firewall by hand |
| AWS | Transparent usage pricing and private service DNS | ECS, RDS, ElastiCache, IAM, and VPC work before n8n boots |
| Hetzner | Managed queue mode without SSH | Low VPS cost, but you operate Redis, Postgres, and workers |
Common Use Cases for hosted n8n AI Agent
Common use cases for n8n AI Agent:
- Chat Trigger → AI Agent + model: staff or customer chat with tool-using agents on your HTTPS domain.
- HTTP Request Tool: the agent calls internal APIs, CRMs, or status endpoints mid-turn.
- Workflow Tool and Code: wrap existing n8n workflows or JS/Python as tools the agent can invoke.
- Calculator plus Postgres Chat Memory: math steps and durable sessions across worker executions.
Dependencies for n8n AI Agent Docker hosted on Railway
Queue-mode n8n for AI agents needs PostgreSQL, Redis as the Bull queue, a volume for the encryption key, and a worker sharing the image tag and N8N_ENCRYPTION_KEY as the editor.
Deployment Dependencies for Managed n8n AI Agent Service (OSS LangChain Agents)
Managed n8n AI Agent on Railway uses official n8nio/n8n:2.36.8 for editor and worker, Postgres (DB_TYPE=postgresdb), Redis for QUEUE_BULL_REDIS_HOST, volume /home/node/.n8n, and a public domain on port 5678 with /healthz.
Implementation Details for n8n AI Agent (Using n8n official docker image)
This template runs official n8nio/n8n:2.36.8 (do not ship latest). The editor uses EXECUTIONS_MODE=queue and serves the UI plus Chat Trigger. The worker starts with n8n worker and runs the agent loop. Both must share N8N_ENCRYPTION_KEY or credentials fail silently. Set WEBHOOK_URL=https://${{n8n.RAILWAY_PUBLIC_DOMAIN}}, N8N_PROTOCOL=https, N8N_PROXY_HOPS=1, GENERIC_TIMEZONE plus TZ, and EXECUTIONS_DATA_PRUNE=true. SQLite cannot run queue mode. Wire Postgres Chat Memory, not Simple Memory, so history survives worker hops.
How does n8n AI Agent compare against other LangChain Agent platforms
n8n AI Agent vs OpenAI Assistants API (OpenAI Assistants API Alternative)
- Billing: Assistants bills tokens and tool calls in OpenAI's cloud. Self hosted n8n is flat Railway compute plus unlimited Community runs; you still pay your model provider.
- Data ownership: Prompts, tool results, and memory stay in your Postgres. Assistants stores threads on OpenAI.
n8n AI Agent vs LangChain DIY (LangChain DIY Alternative)
- Builder speed: Raw LangChain means Python, FastAPI, and deploys. n8n wires Chat Trigger, Agent, model, tools, and memory visually.
- Ops: DIY still needs HTTPS and a queue. This template ships editor, worker, Postgres, and Redis so long agent loops run off the UI.
n8n AI Agent vs Flowise (Flowise Alternative)
- Canvas vs agent studio: Flowise is a LangChain flowchart UI. n8n is a workflow canvas with 400+ integrations plus the AI Agent node.
- Queue workers: Agent turns run on Redis workers. Flowise self-host still needs you to size the process yourself.
n8n AI Agent vs Dify (Dify Alternative)
- Product shape: Dify is an LLM app platform with its own studio. n8n AI Agent is workflow automation with LangChain agents as nodes.
- Self hosting: Agent runtime stays on your workers; Dify Cloud meters workspace usage.
How to use n8n AI Agent (the OSS LangChain Agents)?
Deploy this template, wait for editor, worker, Postgres, and Redis, then open the HTTPS domain and create the owner account. Add Chat Trigger → AI Agent, connect a chat model, attach HTTP, Workflow Tool, Calculator, and/or Code tools, and wire Postgres Chat Memory. Set WEBHOOK_URL to your Railway HTTPS domain, activate, and publish. Scale workers when agent loops queue up.
How to self host n8n AI Agent on other VPS Services (n8n AI Agent self hosting guide)
Clone the Repository
Download n8n from GitHub or pull n8nio/n8n:2.36.8.
Install Dependencies
Install Docker and Docker Compose. Queue mode needs PostgreSQL 16-18, Redis, and RAM for the editor plus one worker.
Configure Environment Variables
Set the same values on main and workers:
EXECUTIONS_MODE=queueDB_TYPE=postgresdbwith matching Postgres host, user, password, and databaseQUEUE_BULL_REDIS_HOST/PORT/PASSWORDN8N_ENCRYPTION_KEY(identical on every process, never rotate casually)WEBHOOK_URL=https://your-domainandN8N_PROXY_HOPS=1behind a reverse proxy
Start the n8n AI Agent Application
Start Postgres and Redis, then the editor on port 5678 and n8n worker as a second container. Put TLS in front of 5678. On Railway this layout is already split into services.
Official Pricing of n8n AI Agent (n8n AI Agent pricing)
n8n Community Edition is free to self-host under the fair-code Sustainable Use License. No per-execution fee on self-hosted Community. n8n Cloud Starter is around $24/month for 2,500 executions. SSO/SAML need Business/Enterprise. Community Edition has no SSO. You pay Railway for compute, Postgres, Redis, and the volume.
n8n AI Agent cloud vs self hosted comparison (Pricing, features, costs, and more)
n8n Cloud is convenient and capped. Self hosted n8n AI Agent on Railway is unlimited Community executions, your encryption key, community nodes Cloud blocks, workers for long agent loops, and HTTPS for Chat Trigger.
Monthly cost of self hosting n8n AI Agent on Railway
Typical cost for editor + worker + Postgres + Redis is about $10-$25/month depending on worker CPU, agent traffic, and disk. Heavy model and tool workflows need more RAM. The cheapest n8n without queue mode costs less with no worker or Redis.
System Requirements for Hosting n8n AI Agent on a VPS
Plan for 2 vCPUs and 4GB RAM as a baseline (editor idle is hundreds of MB, spikes toward 1-2GB, plus Postgres and Redis). Store workflows on Postgres, keep /home/node/.n8n on disk, and expose 5678 behind HTTPS.
Frequently Asked Questions (FAQs)
What is n8n AI Agent self hosted?
n8n AI Agent self hosted means running Community Edition with Chat Trigger, an AI Agent node, a chat model, tools, and Postgres Chat Memory on an editor, Redis queue, Postgres, and workers so LangChain-style agents run on your stack instead of Cloud.
Why use Postgres Chat Memory instead of Simple Memory in queue mode?
Simple Memory is process-local. In queue mode the next chat turn may land on a different worker, so the window is empty. Postgres Chat Memory writes sessions to the same database the editor and workers already share.
How much does n8n AI Agent self hosting cost on Railway?
This workers template typically runs about $10-$25/month on Railway for editor, worker, Postgres, and Redis with unlimited Community Edition executions.
Is n8n AI Agent free to use?
Yes. Community Edition is free to self-host. You pay only for infrastructure and model APIs. Cloud plans and enterprise features (SSO, multi-main) are paid. Check the fair-code license before offering n8n as a hosted service.
Why do AI agents need WEBHOOK_URL and queue workers?
Chat Trigger needs a public HTTPS URL; without WEBHOOK_URL and N8N_PROXY_HOPS=1, chat activation fails. Queue workers (EXECUTIONS_MODE=queue, n8n worker) run agent loops off the editor. Set N8N_ENCRYPTION_KEY and EXECUTIONS_DATA_PRUNE.
What are some alternatives to n8n AI Agent?
OpenAI Assistants API, LangChain DIY, Flowise, Dify, and n8n Cloud. n8n AI Agent is the self-hosted canvas with workers. For a lighter instance use the cheapest n8n without queue mode.
Template Content
Redis
redis:8.2n8n-worker
n8nio/n8n:2.36.8