To install n8n on a VPS, use Docker Compose on a Linux server with at least 4 GB of RAM and 2 vCPUs, start the stack with docker compose up -d, and open the editor on port 5678. The self-hosted Community Edition is free under n8n's Sustainable Use License. In our worked example, self-hosting avoids the €600-a-year Pro subscription.
Your automation bill grows every time a workflow runs. That is the quiet tax of hosted automation: the better your system works, the more it costs. When you install n8n on a VPS, the meter changes. Your workflows run on a server you already control, and the licence fee for the Community Edition is €0.
Quick Answer
To install n8n on a VPS, use Docker Compose on a Linux server with at least 4 GB of RAM and 2 vCPUs, start the stack with docker compose up -d, and open the editor on port 5678. The self-hosted Community Edition is free under n8n’s Sustainable Use License. In our worked example below, self-hosting avoids the €600-a-year Pro subscription.
In this article
- How we checked this guide
- What n8n replaces, and what it does not
- How n8n workflow automation works
- Routes: Community Edition, n8n Cloud, or Business
- Requirements before you install n8n on a VPS
- Step 1: prepare the VPS and Docker
- Step 2: create the Compose project
- Step 3: start n8n and open the editor
- Step 4: add your domain and HTTPS
- Step 5: switch to PostgreSQL for production
- Step 6: build and test your first workflow
- First-login security steps you must not skip
- Backup and update routine
- Common errors and fixes
- Tips and tricks that save money
- The real cost maths
- When not to self-host n8n
- Pros and cons
- Our verdict
- FAQ
- Strategic Pivot
- Sources
How we checked this guide
We verified every install command, requirement, and licence fact on the official n8n GitHub repository and the official n8n documentation on December 3, 2026. Paid comparison prices come from the official n8n pricing page, checked the same day. Nothing here is copied from a roundup.
Where the official pages name a limit — a RAM floor, a licence restriction, a plan price — we say so plainly. If a claim could not be verified on an official page, it stays out of this guide.
What n8n replaces, and what it does not
n8n replaces the per-execution automation bill. Hosted tools charge you every time a workflow runs, so a busy month of lead alerts, invoice reminders, and AI replies becomes a bigger invoice. Self-hosted n8n runs those same workflows on your VPS. The number of runs is limited by your server, not by a plan allowance.

It also replaces the fragile chain of one-off scripts. Instead of a cron job here and a webhook script there, you build each automation on a visual canvas. Nodes connect your apps, and code nodes handle the odd cases a visual block cannot.
What n8n does not replace is judgement about what to automate. It will happily run a bad process a thousand times. It also does not replace the apps themselves: your CRM, mailbox, and spreadsheets stay where they are. n8n is the conveyor belt between them. If you are still choosing an automation platform, compare our Zapier alternatives for small business automation and our best AI automation tools guide before you commit.
Think of n8n as a switchboard in your office. Calls come in from one app, and the board routes them to the right desk. The board does not do the work. It makes sure the work reaches the right place.
Best for: owners and operators who run automations every day and already have, or can manage, a small Linux server. Skip if: nobody on your team can secure and update a server — n8n Cloud will feel easier and safer.
How n8n workflow automation works
An n8n workflow is a chain of nodes on a canvas. A trigger node decides when the chain starts: a schedule, a webhook from another app, or a new message in a tool you connected. Action nodes then move data along the chain. Each complete run of the workflow is one execution.
That execution definition matters for cost. n8n’s pricing page states that you pay when a workflow runs from start to finish, not per step or per user. On n8n Cloud, executions are capped by plan. On your own VPS, there is no vendor cap. Your ceiling is CPU, memory, and how well you designed the workflow.
Nodes cover both simple and serious work. Built-in integrations connect common business apps. HTTP nodes call any API. Code nodes run JavaScript or Python when a visual block is not enough. AI nodes let a workflow call a model, classify a message, or draft a reply inside the same chain.
One honest limit belongs here, not in a footnote. n8n itself recommends self-hosting for expert users. Its documentation warns that mistakes can lead to data loss, security issues, and downtime. That warning is the price of the €0 licence, and this guide treats it seriously.
Routes: Community Edition, n8n Cloud, or Business
n8n offers three practical routes. Choosing well matters more than any single setting.
| Route | Licence / price anchor | Best for | Skip if |
|---|---|---|---|
| Community Edition (self-hosted) | €0 licence, Sustainable Use License | Teams who want uncapped executions on their own server | Nobody can maintain a Linux server |
| n8n Cloud Starter | €20/month, billed annually | First automations with zero server work | Execution volume will outgrow the cap |
| n8n Cloud Pro | €50/month, billed annually | Small teams running automations in production | You want data and runs on your own hardware |
| Business (self-hosted) | €667/month, billed annually | Companies under 100 employees needing collaboration and scale | You only need the core automation engine |
The Community Edition is the route this guide installs. It is the standard self-hosted version available on GitHub, and it carries no licence fee. The Cloud plans trade money for convenience: n8n runs the servers, and you stay inside an execution allowance. Business adds collaboration and scale features on your own infrastructure, at a price that only makes sense for larger teams.
Requirements before you install n8n on a VPS
Start with the server. The official Docker Compose guide asks for Docker Engine and Docker Compose v2, plus at least 4 GB of RAM and 2 vCPUs. That floor exists because the current Compose stack includes a sandbox service that runs AI-generated code and needs more headroom than a typical container.

For production, n8n recommends a 64-bit Linux host. It also recommends PostgreSQL as the database. SQLite, the built-in default, suits testing and small setups. It is not recommended for multi-user production use, and it is not supported in queue mode.
Plan the network before you install anything. n8n listens on port 5678 by default. PostgreSQL uses port 5432. Your reverse proxy or load balancer should be the only public door, serving your domain over HTTPS. The documentation is explicit: do not expose the n8n process directly to the internet.
Finally, check the licence position for your use. n8n is fair-code, not OSI open source. The Sustainable Use License lets you use and modify the software for your own internal business purposes. It does not let you resell n8n as a hosted service to others. Enterprise features in .ee. files need a paid Enterprise License. For a small business automating its own work, the free route is permitted.
Step 1: prepare the VPS and Docker
Choose a 64-bit Linux VPS with at least 4 GB of RAM and 2 vCPUs. Create a normal user account for daily work. Keep root login for emergencies only.
Install Docker Engine and the Docker Compose v2 plugin using Docker’s own instructions for your distribution. Then confirm both tools respond:
docker --version
docker compose versionEach command should print a version number. If the second command fails, the Compose plugin is missing. Fix that first, because every later step depends on it.
Point a subdomain at the server now. A name such as n8n.example.com needs a DNS record that resolves to your VPS. You will use that hostname for the editor, for webhooks, and for the TLS certificate. Doing DNS early saves waiting later, because certificates cannot be issued until the name resolves.
Set the server timezone to your business timezone. Scheduled workflows read the clock you give them. A server left on a default timezone will fire your morning report at the wrong hour, and you will blame n8n for your own setting.
Step 2: create the Compose project
Create a project folder and move into it:
mkdir n8n && cd n8n
The official Compose guide builds the stack by hand. It defines n8n itself, the sandbox services that power n8n Assistant, and a bundled search service. It also keeps n8n’s data in a Docker volume, so your workflows and encryption key survive restarts.
Create the .env file the guide describes. It holds the n8n version to run and the secrets the sandbox services use to talk to each other. Generate your own values for every placeholder, and keep this file out of version control. Secrets in a Git repository are secrets no longer.
Create the search settings file the guide specifies, then create the compose.yml file from the official example in the n8n repository. Copy it from the official source, not from a blog post. Compose examples change as n8n evolves, and a stale file is a common cause of a stack that will not start.
Two settings deserve attention before first boot. Set your timezone so schedule triggers fire when you expect. Generate a custom encryption key with openssl rand -hex 32 and store it somewhere safe. That key protects your saved credentials. Lose it, and every credential in the instance becomes unreadable.
Step 3: start n8n and open the editor
Start the stack in the background:
docker compose up -d
docker compose psWait until the services report healthy. Then verify n8n itself is answering:
curl -sf http://localhost:5678/healthzOpen the editor in your browser at the server address on port 5678. On first launch, n8n asks you to create the owner account. Use a strong password and an email address you control. This account is the keys to every credential you will store, so treat it that way.
Do not connect real business accounts yet. First confirm the editor loads, the version is the stable release you pinned, and a manual test workflow runs. A two-node test — a manual trigger and a simple set node — proves the engine works before you trust it with customer data.
Pin the version you tested. n8n releases a new minor version most weeks. The stable line is for production use, and the beta line may be unstable. Recording the exact version in your .env file means a rebuild next quarter reproduces today’s behaviour instead of surprising you.
Step 4: add your domain and HTTPS
A public n8n needs a proper front door. Put a reverse proxy or load balancer in front of the container. Terminate TLS at that proxy, with a certificate for your subdomain. Port 5678 stays private behind it.
Tell n8n its public address. The production guide names three variables: N8N_HOST takes the hostname, while N8N_EDITOR_BASE_URL and N8N_WEBHOOK_URL take full URLs such as https://n8n.example.com/. Behind a proxy, also set N8N_PROXY_HOPS so n8n trusts the forwarded headers correctly.
Webhook URLs are where this step pays off. External services such as payment providers and form tools call your workflows at a public address. If that address is wrong, triggers silently never fire. Set the webhook URL once, correctly, before you build anything that depends on it.
Test from outside your own network. Open the editor through the domain, confirm the certificate is valid, and confirm the plain port is not reachable from the internet. If both checks pass, your front door is doing its job.
Step 5: switch to PostgreSQL for production
SQLite is fine for trying things out. The documentation says so plainly. For a production instance with more than a handful of users, or workflows running around the clock, use PostgreSQL instead.
Add the Postgres credentials to your .env file. Add a postgres service to your Compose file, with a volume for its data. The official example uses the postgres:18 image and sets PGDATA so the data stays inside the volume mount. Do not remove that line: without it, Postgres 18 writes somewhere the volume does not cover, and your database starts empty.
Point n8n at the new database. Set DB_TYPE to postgresdb and fill in the host, port, database, user, and password variables. Make the n8n service wait for Postgres to report healthy before it starts. Then restart the stack:
docker compose up -dn8n migrates itself to the new database on startup. Existing SQLite data does not carry over automatically. This step is for a fresh instance, not an in-place migration. If you already built workflows on SQLite, export them first and import them after the switch.
Keep the n8n data volume even with PostgreSQL. The .n8n directory still holds the encryption key, instance logs, and other important data. Deleting that volume because “the database is in Postgres now” is an expensive misunderstanding.
Step 6: build and test your first workflow
Start with one workflow that earns its keep. A good first candidate is a lead alert: a form submission triggers a message to your team chat and a row in a spreadsheet. It is small, visible, and easy to verify.
Build it in stages. Add the trigger first and run it with test data. Check the output of every node before you add the next one. n8n shows each node’s data as it flows, so use that view instead of guessing where a value went wrong.
Connect credentials one at a time. Each connected app asks for an API key or an OAuth sign-in. Create those keys with the narrowest permissions the workflow needs. A workflow that only reads a spreadsheet should not hold a key that can delete your drive.
Activate the workflow only after a clean test run. Then send one real event through it and watch the execution log. A workflow that ran once by hand and once for real is ready. A workflow that has only ever run by hand is a hope, not a system.
Add error handling before you scale up. Decide what happens when an app is down: retry, log, or alert a human. Silent failure is the worst outcome, because the business believes the automation ran. A simple error notification turns a hidden outage into a five-minute fix.
First-login security steps you must not skip
The owner account you created is the master key. Protect it first. Use a long, unique password. Store it in a password manager, not in a note on the server.
Keep the encryption key safe and consistent. The production checklist asks for a generated key, stored securely, set to the same value on every n8n instance. Back it up away from the VPS. A backup of the database without the key cannot restore your credentials.
Keep port 5678 private. Only your reverse proxy should reach it. PostgreSQL’s port 5432 should never face the internet. Your firewall should allow the proxy to reach n8n, n8n to reach the database, and users to reach the proxy. Everything else stays closed.
Be careful with the sandbox. The Compose guide warns that its sandbox runner is privileged and gives weak isolation. It is built for development and testing. Run that setup on a dedicated host or VM with nothing else on it, and treat production AI code execution as a separate, deliberate decision.
Review who can build workflows. In the Community Edition, anyone who can edit a workflow can reach the credentials it uses. Invite only the people who need that power. A small team with clear ownership beats a long user list nobody audits.
Backup and update routine
Back up three things: the PostgreSQL database, the n8n data volume, and your project files. The database holds workflows, credentials, and execution history. The volume holds the encryption key. The .env and Compose files hold the configuration that ties them together. A backup missing any one of the three is a partial rescue.
Copy backups off the VPS. A backup on the same disk dies with the disk. Schedule the copy, then test a restore on a spare machine or a fresh container. An untested backup is a rumour. A tested restore is a plan.
Update on a rhythm, not on impulse. n8n ships new minor versions most weeks. For a Compose setup, the documented routine is short:
docker compose pull
docker compose down
docker compose up -dTake a backup before you pull. Read the release notes for breaking changes. Update during a quiet hour, then run your most important workflow once by hand. If it passes, the update is done. If it fails, your backup turns a bad evening into a short rollback.
Never delete volumes during an update. docker compose down stops containers. Adding the volume flag deletes your data. That single letter is the difference between an update and a rebuild.
Common errors and fixes
The editor does not load. Check the container state first with docker compose ps. If n8n is restarting, read its logs with docker compose logs n8n. Most first-boot failures are a missing environment variable or a port already in use.
Webhooks never fire. The public webhook URL is probably wrong. Confirm N8N_WEBHOOK_URL matches your real domain, and confirm the domain resolves to the VPS. A workflow can be perfect and still receive nothing if callers are knocking on the wrong address.
Credentials break after a restart. The encryption key changed or the data volume was lost. Restore the original key and volume from backup. This is why the key is generated once, stored safely, and never regenerated casually.
Postgres starts empty after an upgrade. Postgres 18 changed its default data location. If PGDATA is missing, the new server writes outside your volume. Restore from backup, set PGDATA as the official example does, and start again. Moving an old Postgres to version 18 is a major upgrade: back up with pg_dumpall first.
The sandbox services fail to start. Check whether the certificate step completed, and read the sandbox logs. Missing sandbox environment variables are the usual cause. The Compose guide’s troubleshooting table names the exact variables to check.
Scheduled workflows fire at the wrong time. The timezone variables are unset or wrong. Set both the system timezone and n8n’s timezone setting to your business timezone, then restart the stack.
Tips and tricks that save money
Batch where you can. A workflow that processes one item per run spends server time on overhead. A workflow that gathers items and processes them together finishes faster and leaves more headroom for everything else.
Watch execution history growth. Every run writes history to the database. Prune old executions on a schedule so the database stays lean. A bloated database slows the editor long before it fills the disk.
Reuse sub-workflows. When three workflows all send the same alert format, build that alert once and call it. One fix then repairs three workflows. Copy-pasted nodes drift apart, and drift becomes bugs.
Keep test and production apart. Build changes in a copied workflow, test with sample data, then move the change into the live workflow. Editing a live automation during business hours is how a small fix becomes an outage.
Name workflows like you mean it. “Lead alert — website form to team chat” tells the next person what breaks if it stops. “Workflow 47” tells them nothing. Six months from now, that next person is you.
The real cost maths
Here is the comparison with real numbers. n8n Cloud Starter costs €20 a month billed annually. Pro costs €50 a month billed annually. Business, which is self-hosted only, costs €667 a month billed annually. Those figures come from the official pricing page, checked on December 3, 2026.

Now run a realistic small-business scenario. A service business runs lead alerts, invoice reminders, review requests, and AI-drafted replies. The team is small, but the automations run all day. On Cloud, that profile fits the Pro plan: €50 a month, which is €600 a year.
Self-hosted, the same business pays €0 in n8n licence fees. The cost that remains is the VPS. If the business already runs a server with spare capacity, the marginal cost of n8n is close to zero, and the full €600 a year stays in the business. If a new VPS is needed, subtract its real monthly price from the €600. The saving shrinks, but the execution cap disappears either way.
The full stack tells the other half of the story. Business at €667 a month is €8,004 a year. That tier buys collaboration and scale features a small team rarely needs on day one. The lean choice is Community Edition on your own VPS. The expensive mistake is buying scale features before you have scale.
Two costs sit outside both routes. AI model usage is billed by the model provider, whichever route you choose. And your time has a price: self-hosting trades a subscription for maintenance. The maths favours self-hosting when executions are frequent and someone competent owns the server.
When not to self-host n8n
Do not self-host if nobody will maintain the server. Updates, backups, and security patches are now your job. An unpatched automation server holding business credentials is a liability, not an asset.
Do not self-host if you need enterprise identity features today. Single sign-on, environments, and Git version control sit in paid tiers. If your compliance rules require them, budget for Business or Enterprise instead of fighting the Community Edition.
Do not self-host if your business model is selling automation access to clients. The Sustainable Use License permits use for your own internal business purposes. It does not permit offering n8n itself as a hosted service to others. Agencies should read the licence before building a client product on it.
Do not self-host for a handful of monthly runs. At low volume, Starter at €20 a month billed annually is cheaper than your maintenance time. Self-hosting wins when volume is steady and the server already exists.
Pros and cons
Pros
- €0 licence fee for the Community Edition, with no vendor execution cap.
- Your data, credentials, and execution history stay on your own server.
- Visual building with code nodes when a workflow needs custom logic.
- Docker Compose setup with PostgreSQL for production growth.
- One platform for app automation and AI workflows together.
Cons
- You maintain the server, updates, backups, and security yourself.
- n8n recommends self-hosting for expert users; mistakes can cause data loss.
- Enterprise features such as SSO need a paid licence.
- The licence is fair-code, not OSI open source, and resale as a service is barred.
- No vendor support desk or uptime guarantee on the free route.
Our verdict
Install n8n on a VPS when automations run every day and someone competent owns the server. The maths is not close: €0 in licence fees against €600 a year for Pro, with no execution cap on your own hardware. Choose n8n Cloud when volume is low, maintenance capacity is zero, or your team needs vendor-run infrastructure. Either way, decide with your real execution volume in hand, not with a guess.
FAQ
Is n8n free to self-host for a business?
Yes. The Community Edition carries no licence fee, and the Sustainable Use License permits use for your own internal business purposes. It is fair-code rather than OSI open source, and offering n8n as a hosted service to others is not permitted. Enterprise features need a paid licence.
What VPS size does n8n need?
The official Docker Compose guide asks for at least 4 GB of RAM and 2 vCPUs, with Docker Engine and Compose v2. For production, n8n recommends a 64-bit Linux host and PostgreSQL. Heavier AI workflows need more headroom than the floor.
Does self-hosted n8n limit executions?
No vendor cap applies on your own server. Your limits are CPU, memory, and workflow design. On n8n Cloud, executions are capped by plan, and runs at the limit fail instead of queueing. That difference is the core of the cost comparison.
Should I use SQLite or PostgreSQL?
SQLite suits testing and small setups. PostgreSQL is recommended for production, for more than a handful of users, and for workflows running around the clock. SQLite is not supported in queue mode. Switching later means exporting workflows, because data does not carry over automatically.
How do I update self-hosted n8n?
Back up first. Then run docker compose pull, docker compose down, and docker compose up -d. Test your most important workflow after the restart. Never add the volume-deletion flag to the down command, because that deletes your data.
Strategic Pivot
Self-hosting removes the execution meter, but your full automation stack still has model usage and server lines to budget. Before you commit to a route, run your own execution volume through our AI Cost Calculator and compare the Cloud bill against the self-hosted habit with your real numbers, not ours.
Sources
- Official n8n GitHub repository: n8n-io/n8n
- Official n8n documentation: install with Docker, install using Docker Compose, and production requirements pages.
- Official n8n pricing page: Starter, Pro, Business, and Community Edition details.
- Official n8n licence file: Sustainable Use License, Version 1.0.
Price note — updated December 3, 2026: Prices in this post were checked on December 3, 2026. When you are reading this, the price may be lower or higher. Check the official n8n pricing page before you buy.
Related: How to Install Activepieces Self-Hosted Automation (2026)
Pros
- €0 licence fee for the Community Edition with no vendor execution cap
- your data, credentials, and execution history stay on your own server
- visual building with code nodes when a workflow needs custom logic
- Docker Compose setup with PostgreSQL for production growth
- one platform for app automation and AI workflows together
Cons
- You maintain the server, updates, backups, and security yourself
- n8n recommends self-hosting for expert users and mistakes can cause data loss
- enterprise features such as SSO need a paid licence
- the licence is fair-code, not OSI open source, and resale as a service is barred
- no vendor support desk or uptime guarantee on the free route
Install n8n on a VPS when automations run every day and someone competent owns the server. The maths is not close: €0 in licence fees against €600 a year for Pro, with no execution cap on your own hardware. Choose n8n Cloud when volume is low, maintenance capacity is zero, or your team needs vendor-run infrastructure.

2 thoughts on “How to Install n8n on a VPS With Docker (2026)”