The Complete n8n Guide: Install, Build AI Agents, Scale, and Secure Your Instance

Introduction

n8n is a node-based workflow automation platform that you can run on n8n’s cloud or on your own server, and it has become a popular choice for teams that want automation and AI agents without per-task pricing. This guide is the map of everything we have published about n8n on ToolPilot: 62 hands-on tutorials organized into the order you will actually need them, from your first install to queue mode scaling and emergency patching. New readers should follow the sections in order. Experienced users can jump straight to the section that matches the problem in front of them.

Quick answer

n8n is worth using if you want workflow automation you control: it is free to self-host under the Sustainable Use License, connects hundreds of services through prebuilt nodes, and includes a native AI Agent node for LLM-powered workflows. Start with Docker Compose, build one agent, then scale with PostgreSQL and queue mode.

Evidence

The case for n8n starts with its community. The n8n repository on GitHub counted 208,133 stars and 61,194 forks as of October 21, 2026, which makes it one of the most watched automation projects in the world and means most problems you hit have already been solved in public. The database story points the same direction. In the Stack Overflow 2025 Developer Survey, PostgreSQL was the most used database at 55.6% of respondents, and PostgreSQL is the database n8n itself recommends for production, so the skills you build here transfer to the rest of your stack.

The official n8n Docker Compose install guide gives the clearest verdict on where a trial install should end up: “SQLite is fine for trying things out, but for a production instance that must handle more than a handful of users or workflows running around the clock use Postgres instead.” The same documentation set explains the AI side of the platform: the advanced AI tutorial walks through building agents on n8n’s LangChain-based nodes, which is the foundation every agent tutorial in this guide builds on. Treat those two pages as the canonical references behind this guide; everything below is the hands-on layer on top of them.

Getting started and deployment

Install n8n once, the boring way, and every later tutorial in this guide gets easier. Our default stack is Docker Compose on an Ubuntu VPS with PostgreSQL and a reverse proxy that provides HTTPS, because that combination survives upgrades, restarts, and real traffic. The npm install still works for a quick local trial, but it is a dead end for production: n8n 3.0 drops npm support entirely, so anything you plan to keep should start on Docker.

Two habits matter more than the install command itself. First, pin the version you deploy and upgrade on a schedule you control, reading the release notes before you pull a new image. Second, protect your data directory and its encryption key from the first day, because losing the key means losing every stored credential with it. If you inherit an older npm install, migrate it to Docker before you do anything else, and if your instance still runs on SQLite, plan the move to PostgreSQL before the workflow count grows.

Building AI agents

n8n’s AI Agent node turns a workflow into a reasoning loop: a chat model decides which tools to call, reads the results, and answers in plain language. Build your first agent small, with one channel and two or three tools, and only add memory, sub-agents, and extra channels once the basic loop is reliable. The Agent Builder shortens that first build by generating an agent scaffold from a description, which you then refine by hand.

The failures in this section are the ones every agent builder meets. Agents ignore their tools when tool descriptions are vague, so write descriptions like instructions to a colleague. Agents repeat side effects when several executions race, so give concurrent agents an atomic claiming pattern before they touch shared data such as calendars or inboxes. Chat memory is the difference between a demo and an assistant, and it belongs in PostgreSQL once the bot serves real users. Local models through Ollama work well for private or offline agents, as long as the model you pick actually supports tool calling.

RAG and data

Retrieval-augmented generation is the pattern behind most useful n8n AI projects: split your documents into chunks, embed them into a vector store, and let the agent retrieve the relevant chunks before it answers. The quality of the answer depends mostly on chunking and on matching your embedding model’s dimensions to the store, not on the size of the chat model. Qdrant is our default self-hosted store and Pinecone is the managed option, and the same Vector Store node drives both.

Data discipline matters just as much underneath the AI layer. PostgreSQL plays three roles in a mature n8n setup: it is the database n8n itself runs on, the memory store for production chatbots, and a general automation target you can query from any workflow. If your instance still runs on SQLite, migrate before you build RAG on top of it, because the migration gets slower and riskier as executions pile up.

Integrations and migrations

n8n earns its place in a stack by connecting things, and the Model Context Protocol has become the most important connection of all. n8n works on both sides of MCP: it can expose your workflows as tools that Claude Code and other MCP clients call directly, and its agents can consume tools from external MCP servers. That two-way support is why n8n increasingly sits in the middle of AI tooling instead of at the edge.

Migrations follow a repeatable pattern. Inventory what the old platform actually runs, map each trigger and action to n8n nodes, rebuild the highest-volume workflow first, and run both systems in parallel until the numbers match. The Zapier migration guide works through a real example, and the Make comparison settles the platform choice for agent workloads before you commit. Specialist nodes cover the long tail, from Microsoft Dataverse business data to programmatic PDF processing with pdfRest. Finally, most “my webhook stopped working” reports trace back to one missing environment variable behind a reverse proxy, and the fix takes five minutes once you know where to look.

Security and patching

Self-hosting trades a subscription bill for a responsibility: when n8n publishes a security fix, nobody applies it for you. The year 2026 made that concrete. The Ni8mare vulnerability (CVE-2026-21858) scored a perfect CVSS 10.0 and allowed unauthenticated remote code execution through webhooks, and CVE-2026-44791 scored CVSS 9.4 in the XML node. Monthly security bulletins have become routine, and several September advisories shipped without CVE IDs at all, which means vulnerability scanners that key on CVE numbers simply never flagged them.

Build a patching routine instead of reacting to headlines. Watch the official advisories, test each upgrade on a copy of your instance, patch production within days for critical fixes, and rotate credentials after any remote-code-execution fix, because a patched server can still hold stolen keys. Restrict who can reach the editor, keep the instance behind HTTPS, and treat every tutorial in this section as a drill you run before the next bulletin lands, not after.

Operations and troubleshooting

Production n8n is mostly plumbing. Queue mode is the scaling step: one main instance accepts work, Redis queues it, and worker processes execute in parallel, exactly the architecture the official n8n scaling documentation describes. Queue mode requires PostgreSQL, which is why the database migration appears so early in this guide. In n8n 3.0, Code nodes move to external task runners, a separate sidecar that isolates code execution and lets you control which JavaScript and Python libraries workflows may use.

Reliability work is less glamorous and more valuable. Give every important workflow an error path, use retries with idempotency keys so a retried payment call cannot charge a customer twice, and consider durable execution when a crashed run must resume instead of restart. The troubleshooting guides cover the failures self-hosters actually report: the “Connection lost” banner behind NGINX is a WebSocket proxying problem, “Database not ready” is usually SQLite bloat, and most post-update breakage comes from a short list of causes that includes renamed variables and removed nodes.

Code node and power features

The Code node is where n8n stops being a no-code tool and becomes a development platform. One Code node with the right run mode replaces a chain of utility nodes, and it is the natural home for data transforms that expressions make awkward: reshaping nested JSON, merging items, and computing values across a whole batch. Learn the two run modes, the $input helpers, and the { json } return format, and most workflow logic becomes straightforward. Debugging is fast once you know how the editor surfaces console output from a run.

The Assistant covers the opposite end of the skill range. Describe the workflow you want in plain language, review the plan it proposes, and connect your credentials yourself rather than pasting secrets into a prompt. Our verdict: use the Assistant to draft, the visual editor to refine, and the Code node when the logic outgrows both.

FAQ

Is n8n free to use? Self-hosted n8n is free under the Sustainable Use License, which covers running n8n for your own business and internal automation, so your only cost is the server it runs on. n8n Cloud is a paid subscription, and a small set of enterprise features requires a paid license on either deployment type.

Should I choose n8n Cloud or self-hosting? Self-hosting is usually cheaper at volume because executions are not metered, and a small VPS handles thousands of runs a month. Cloud is the better choice when nobody on the team wants to own updates, backups, TLS certificates, and security patches. The real trade-off is operations time, not the subscription price.

How does n8n compare with Zapier and Make? Zapier and Make are fully hosted and charge per task or per operation, which makes them effortless to start and expensive to scale. n8n can be self-hosted for a flat server cost, gives you a Code node and local AI models, and keeps your data on your own machines. Our n8n vs Make comparison works through the pricing math for agent workloads in detail.

Do I need to know how to code to use n8n? No. Most workflows are built by connecting prebuilt nodes on a visual canvas, and built-in expressions handle everyday data mapping. Coding is optional: the Code node accepts JavaScript when a workflow outgrows the prebuilt nodes, and learning a little of it multiplies what you can automate.

Can n8n scale to production workloads? Yes. Move the database from SQLite to PostgreSQL, switch on queue mode so Redis-backed worker processes share executions, and run Code nodes in external task runners. That is the architecture the official scaling documentation describes, and it handles production traffic comfortably when it is patched and monitored.

Is n8n good for building AI agents? Yes. n8n ships a native AI Agent node built on LangChain, with pluggable chat models, memory sub-nodes, vector stores, and the ability to call any workflow or node as a tool. It also works as both an MCP client and an MCP server, so agents built in n8n can use external tools and external agents can call your workflows.

Conclusion

n8n rewards a specific order of learning: install it properly, automate something small, add an agent, then invest in the database, scaling, and patching work that keeps the whole system trustworthy. If you are starting today, install n8n with the Ubuntu VPS guide, build the Telegram agent from the agents tutorial this week, and add the RAG support chatbot once the basic loop feels boring. Come back to the security section on a schedule, not on a headline. The platform will keep changing, and this guide is updated as our tutorials are, so the path above stays current.

Frequently asked questions

Is n8n free to use?

Self-hosted n8n is free under the Sustainable Use License, which covers running n8n for your own business and internal automation; you pay only for the server it runs on. n8n Cloud is a paid subscription, and a small set of enterprise features requires a paid license on either deployment type.

Should I choose n8n Cloud or self-hosting?

Self-hosting is usually cheaper at volume because executions are not metered, and a small VPS handles thousands of runs a month. Cloud is the better choice when nobody on the team wants to own updates, backups, TLS certificates, and security patches. The real trade-off is operations time, not the subscription price.

How does n8n compare with Zapier and Make?

Zapier and Make are fully hosted and charge per task or per operation, which makes them effortless to start and expensive to scale. n8n can be self-hosted for a flat server cost, gives you a Code node and local AI models, and keeps your data on your own machines. Pick Zapier or Make for zero maintenance, and pick n8n for control, AI agents, and predictable costs.

Do I need to know how to code to use n8n?

No. Most workflows are built by connecting prebuilt nodes on a visual canvas, and built-in expressions handle everyday data mapping. Coding is optional: the Code node accepts JavaScript when a workflow outgrows the prebuilt nodes, and learning a little of it multiplies what you can automate.

Can n8n scale to production workloads?

Yes. Move the database from SQLite to PostgreSQL, switch on queue mode so Redis-backed worker processes share executions, and run Code nodes in external task runners. That is the architecture the official scaling documentation describes, and it handles production traffic comfortably when it is patched and monitored.

Is n8n good for building AI agents?

Yes. n8n ships a native AI Agent node built on LangChain, with pluggable chat models, memory sub-nodes, vector stores, and the ability to call any workflow or node as a tool. It also works as both an MCP client and an MCP server, so agents built in n8n can use external tools and external agents can call your workflows.

TP
ToolPilot Team

We install, break, and fix automation tools so you don't have to. Every tutorial on ToolPilot is tested hands-on before publishing.

Keep reading