Self-hosting n8n means running the automation tool on a server you rent, instead of paying for n8n Cloud. The software is free, a small VPS costs about $6 to $12 a month, and you get unlimited workflows and executions. The trade-off is that updates, backups and security become your job.
We built a full production-style setup with Docker, Postgres and automatic HTTPS, ran 400 webhook calls through it, then deleted everything and restored it from backup. The restore took 27 seconds.
Should you self-host n8n?
Self-hosting suits you if you’re comfortable with a Linux command line, you want to run lots of executions cheaply, or you need data to stay on your own server. n8n Cloud suits you if you’d rather not think about servers at all.
| Self-hosted on a VPS | n8n Cloud | |
|---|---|---|
| Software cost | Free (Community Edition) | Included in the plan |
| Typical monthly cost | $6 to $24 for the server | From $20 a month billed annually |
| Execution limits | None, apart from your server’s power | 2,500 on Starter, 10,000 on Pro |
| Setup | About 45 minutes the first time | Minutes |
| Updates and backups | Your job | Handled for you |
| Where data lives | Your server, your choice of region | n8n’s cloud |
| Best for | High volume, data control, tinkerers | Teams who want no server work |
n8n itself is blunt about this: its docs recommend self-hosting for expert users and point everyone else to Cloud. That’s fair, but the bar isn’t as high as it sounds. If you can follow the steps below, copy files and read an error message, you can run it. What matters more is whether you’ll keep doing the boring parts: updating every few weeks and checking that backups work.
If you’re new to n8n itself, start with our explainer on what n8n is and how it works, or our n8n review for the full feature tour.
What we built and how it performed
We used the same setup we recommend below: n8n 2.49.5 in Docker, a Postgres 16 database, and Caddy as the HTTPS reverse proxy, all managed by one Docker Compose file. We built it on a Debian 13 Linux machine, the same operating system family most VPS providers offer.
| What we measured | Result |
|---|---|
| Versions | n8n 2.49.5, Postgres 16, Caddy 2, Docker 26.1 |
| Time to first start (images already pulled) | Health check passed in 21 seconds |
| Memory at idle | n8n 406 MB, Postgres 30 MB, Caddy 14 MB |
| Memory after 400 webhook calls | n8n 660 MB |
| Webhook speed, one at a time (1 vCPU, 1 GB) | Median 36 ms, 95th percentile 56 ms |
| Webhook speed, 10 at once (1 vCPU, 1 GB) | Median 382 ms, 95th percentile 491 ms |
| Failed requests | 0 of 400 |
| Backup time and size | 12 seconds, under 1 MB |
| Full restore after deleting all data | 27 seconds to a working webhook |
Memory is the number to plan around. n8n used about 406 MB at idle and climbed to 660 MB after our load test. Postgres and Caddy added under 50 MB together. A 1 GB server works, but only just, and a long workflow handling big files would push it into swap. 2 GB is the comfortable minimum, and 4 GB gives you room for heavier workflows.
One CPU core is enough for most people. With n8n capped at one core and 1 GB of RAM, single webhook calls came back in a median of 36 milliseconds. Ten at once slowed to a median of 382 ms, still well under half a second, with no failures. Unless you’re running hundreds of executions a minute, CPU won’t be your bottleneck.
$ docker stats --no-stream
n8n-compose-n8n-1 405.8MiB (idle, after first start)
n8n-compose-postgres-1 30.3MiB
n8n-compose-caddy-1 14.3MiB
$ curl -X POST https://n8n.lab.test/webhook/lab-echo -d '{"msg":"hello from the lab"}'
{"received":"hello from the lab","server_time":"…T20:41:34.891+05:30"}
200 webhook calls, n8n limited to 1 vCPU / 1 GB:
one at a time median 36 ms p95 56 ms 200/200 ok
10 at once median 382 ms p95 491 ms 200/200 ok
Restore drill (volumes deleted, then restored): webhook back in 27 s
Two things went wrong, and both are worth knowing. First, on our lab machine the containers couldn’t reach each other over Docker’s default network, because the machine’s firewall dropped forwarded traffic. n8n sat in a loop of “Could not establish database connection” errors. On a normal VPS this works out of the box; if you see that error, check the firewall’s forwarding rules. Second, a workflow we imported from the command line didn’t start answering webhooks until n8n restarted. Publishing from the editor doesn’t have this delay.
What you need before you start
- A VPS with at least 2 GB of RAM, running Ubuntu 24.04 or Debian 12 or 13. Our guide to what a VPS is covers the basics.
- A domain or subdomain you control, such as n8n.yourdomain.com. HTTPS needs one.
- SSH access to the server, as a user with sudo rights.
- About 45 minutes for the first setup, most of it waiting for downloads.
Choosing a VPS for n8n
Any provider that gives you a Linux server with root access works. The differences are price, renewal terms, where the data centres are, and whether backups cost extra.
| Plan | CPU and RAM | Price | Notes |
|---|---|---|---|
| Hostinger KVM 1 | 1 vCPU, 4 GB | $6.49 a month on a 24-month term | Renews at $11.99; weekly backups included |
| Hostinger KVM 2 | 2 vCPU, 8 GB | $8.79 a month on a 24-month term | Renews at $14.99 |
| DigitalOcean Basic 2 GB | 1 vCPU, 2 GB | $12 a month | Monthly billing; backups +20% weekly |
| DigitalOcean Basic 4 GB | 2 vCPU, 4 GB | $24 a month | Monthly billing |
| Contabo Cloud VPS 4 | 4 vCPU, 8 GB | $6.60 a month monthly, $5.28 on longer terms | Setup fee on monthly billing |
Hostinger gives you the most RAM for the money on its entry plans, and includes weekly backups. The headline prices need a 24-month term, and the renewal price is close to double, so compare the renewal figure too. It also offers a one-click n8n template if you’d rather skip the Docker steps. Our Hostinger review covers its support and control panel.
DigitalOcean charges monthly with no long contract and has clear, flat pricing. Its 1 GB droplet is too tight for n8n with Postgres; start at 2 GB. Automated backups cost 20% extra for weekly or 30% for daily. See our DigitalOcean review.
Contabo offers the most CPU and RAM per dollar, at the cost of slower support and a setup fee on monthly billing. It’s a good fit if you plan to run many heavy workflows.
For more options, see our list of the best VPS hosting services.
How to self-host n8n, step by step
Here’s the whole process at a glance. Each step is explained below with the exact files and commands.
The steps at a glance
-
Step 1 of 8
Point your domain at the server
Add an A record for a subdomain like n8n.yourdomain.com with your VPS’s IP address.
-
Step 2 of 8
Secure the server and install Docker
Update the system, install Docker with the official script, and allow only SSH, HTTP and HTTPS through the firewall.
-
Step 3 of 8
Create the project folder and secrets
Make /opt/n8n-compose with a .env file holding your domain, timezone, database password and encryption key.
-
Step 4 of 8
Write the Docker Compose file
Define three containers: Postgres for data, n8n pinned to a version, and Caddy for HTTPS.
-
Step 5 of 8
Configure HTTPS with Caddy
A two-line Caddyfile gets and renews a free certificate for your subdomain automatically.
-
Step 6 of 8
Start n8n
Run docker compose up -d and watch the logs until the editor is reachable.
-
Step 7 of 8
Create the owner account
Open your n8n URL straight away, create the owner account and turn on two-factor authentication.
-
Step 8 of 8
Test a webhook, then set up backups
Publish a test webhook workflow, call it over HTTPS, then schedule the nightly backup script and test a restore.
Step 1: point your domain at the server
In your domain’s DNS settings, add an A record: name n8n (or whatever subdomain you want), value your server’s public IP address. DNS changes usually take a few minutes. Check it with ping n8n.yourdomain.com from your own computer; the reply should show your server’s IP.
Do this first, because Caddy needs the domain to resolve to your server before it can get an HTTPS certificate.
Step 2: secure the server and install Docker
Log in over SSH, update the system and install Docker with its official script:
sudo apt update && sudo apt upgrade -y
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
docker --version && docker compose version
Then turn on the firewall, allowing only SSH and web traffic:
sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
sudo ufw status
Run sudo ufw allow OpenSSH before ufw enable, or you can lock yourself out. Use SSH keys rather than passwords if your provider supports it. Don’t open port 5678; in this setup, n8n is only reachable through Caddy.
Step 3: create the project folder and secrets
Make a folder for everything, such as /opt/n8n-compose, and create a file called .env inside it:
DOMAIN_NAME=example.com
SUBDOMAIN=n8n
GENERIC_TIMEZONE=Asia/Kolkata
# generate each with: openssl rand -hex 24
POSTGRES_PASSWORD=change-me
N8N_ENCRYPTION_KEY=change-me
The encryption key matters more than anything else in this file. n8n uses it to encrypt every saved credential: your API keys, passwords and OAuth tokens. If you lose it, those credentials can’t be decrypted, even from a perfect backup. Generate it with openssl rand -hex 24, store a copy in your password manager, and never change it after the first start.
Lock the file down with chmod 600 .env so other users on the server can’t read it. Create an empty folder called local-files too, for workflows that read and write files.
Step 4: write the Docker Compose file
Create compose.yaml in the same folder. This is the file we tested, with the lab-only changes removed:
services:
postgres:
image: postgres:16
restart: always
environment:
- POSTGRES_USER=n8n
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=n8n
volumes:
- db_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U n8n -d n8n"]
interval: 5s
timeout: 5s
retries: 10
n8n:
image: docker.n8n.io/n8nio/n8n:2.49.5
restart: always
depends_on:
postgres:
condition: service_healthy
environment:
- DB_TYPE=postgresdb
- DB_POSTGRESDB_HOST=postgres
- DB_POSTGRESDB_DATABASE=n8n
- DB_POSTGRESDB_USER=n8n
- DB_POSTGRESDB_PASSWORD=${POSTGRES_PASSWORD}
- N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}
- N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
- N8N_PROTOCOL=https
- N8N_PORT=5678
- N8N_WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
- N8N_PROXY_HOPS=1
- GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
- TZ=${GENERIC_TIMEZONE}
- NODE_ENV=production
- EXECUTIONS_DATA_PRUNE=true
- EXECUTIONS_DATA_MAX_AGE=336
- N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
- N8N_RESTRICT_FILE_ACCESS_TO=/files
volumes:
- n8n_data:/home/node/.n8n
- ./local-files:/files
caddy:
image: caddy:2
restart: always
ports:
- "80:80"
- "443:443"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile:ro
- caddy_data:/data
volumes:
db_data:
n8n_data:
caddy_data:
What each part does:
- postgres stores workflows, credentials and execution history. n8n can use a built-in SQLite file instead, but Postgres copes better with many executions and is easier to back up while running.
- n8n runs the app. We pin the version (2.49.5) instead of using latest, so it only changes when you decide to update.
- N8N_WEBHOOK_URL and N8N_PROXY_HOPS tell n8n it sits behind a proxy on HTTPS, so webhook URLs in the editor show your real domain.
- EXECUTIONS_DATA_PRUNE and EXECUTIONS_DATA_MAX_AGE delete execution history after 336 hours (14 days). Without them, the database grows forever.
- caddy is the only container with public ports. It gets and renews a free Let’s Encrypt certificate automatically.
Step 5: configure HTTPS with Caddy
Create a file called Caddyfile with two lines of real config:
n8n.example.com {
reverse_proxy n8n:5678
}
Replace n8n.example.com with your own subdomain. That’s the whole HTTPS setup: Caddy requests the certificate on first start and renews it before it expires. n8n’s own guide uses Traefik instead, which works just as well but needs more configuration.
Step 6: start n8n
From the project folder, run docker compose up -d. The first start pulls images that take about 1.9 GB on disk once unpacked, so it takes a minute or two on a VPS. In our lab, n8n answered its health check 21 seconds after the containers started, while it set up the database.
Watch the logs with docker compose logs -f n8n. When you see “Editor is now accessible”, open https://n8n.yourdomain.com in your browser.
Step 7: create the owner account
The first person to open the editor creates the owner account. Do this straight away, because until you do, anyone who finds the URL could claim it. Use a strong password and turn on two-factor authentication in your user settings.
Step 8: test a webhook
Create a workflow with a Webhook trigger, set the method to POST, publish it, and call the production URL with curl or any HTTP tool. Our test workflow echoed back the message we sent with the server time, and answered in about a tenth of a second. If you’re new to webhooks, our guide to how webhooks work in n8n explains test and production URLs.
Backups you can actually restore
A backup you’ve never restored is a guess. We tested ours the hard way: we deleted the containers and every data volume, restored from the backup files, and checked that the webhook answered again. It did, 27 seconds later.
A complete n8n backup has three parts:
| Part | Why you need it | How we back it up |
|---|---|---|
| Postgres database | Workflows, credentials (encrypted), users, execution history | pg_dump in custom format |
| n8n data volume | Settings file with the encryption key, plus local data | A tar archive of the volume |
| The .env file | Your encryption key and database password | A copy in the same backup folder, plus your password manager |
This script backs up all three and keeps 14 days of copies:
#!/bin/bash
# /opt/n8n-compose/backup.sh : nightly n8n backup, keeps 14 days
set -e
cd /opt/n8n-compose
D=backups/$(date +%F)
mkdir -p "$D"
docker compose exec -T postgres pg_dump -U n8n -Fc n8n > "$D/n8n-db.dump"
docker run --rm -v n8n-compose_n8n_data:/data -v "$PWD/$D":/out alpine \
tar czf /out/n8n-data.tgz -C /data .
cp .env "$D/env.backup"
find backups -maxdepth 1 -type d -mtime +14 -exec rm -rf {} +
Make it executable with chmod +x backup.sh and run it nightly with cron: run crontab -e and add the line 30 2 * * * /opt/n8n-compose/backup.sh. Our backup took 12 seconds and produced under 1 MB of files for a fresh instance; yours will grow with execution history.
Copy backups off the server. A backup on the same VPS disappears with the VPS. Sync the backups folder to cloud storage, or use your provider’s snapshot backups as a second layer.
To restore onto a fresh server, put compose.yaml, Caddyfile and the backed-up .env in place, then:
cd /opt/n8n-compose
docker compose down
docker volume rm n8n-compose_db_data n8n-compose_n8n_data
docker compose up -d postgres
sleep 10
docker compose exec -T postgres pg_restore -U n8n -d n8n --clean --if-exists < backups/YYYY-MM-DD/n8n-db.dump
docker volume create n8n-compose_n8n_data
docker run --rm -v n8n-compose_n8n_data:/data -v "$PWD/backups/YYYY-MM-DD":/in alpine \
sh -c 'tar xzf /in/n8n-data.tgz -C /data && chown -R 1000:1000 /data'
docker compose up -d
Updating n8n safely
n8n releases new versions most weeks. You don’t need every one, but don’t fall months behind either: updates include security fixes, and jumping several major versions at once is where upgrades break.
cd /opt/n8n-compose
./backup.sh
# change the n8n image tag in compose.yaml, e.g. 2.49.5 -> the new stable version
docker compose pull n8n
docker compose up -d
docker compose logs -f n8n
Read the release notes before a major version jump, and always run the backup first. If an update goes wrong, change the image tag back to the old version and restore the database backup you just made.
Securing your instance
Self-hosting makes you responsible for security. These are the settings that matter most:
- Keep port 5678 closed. Only Caddy should be public. Our compose file doesn’t publish n8n’s port at all.
- Use two-factor authentication for every user account.
- Update the server with
sudo apt update && sudo apt upgradeevery few weeks, as well as n8n itself. - Restrict file access.
N8N_RESTRICT_FILE_ACCESS_TO=/filesstops workflows reading files outside the shared folder. - Protect webhook endpoints. Add header authentication or a secret in the URL for webhooks that trigger anything sensitive.
- Be careful with community nodes. They run code on your server with n8n’s permissions. Install only ones you trust.
Monitoring: know when it stops
A self-hosted n8n that stops quietly is worse than one that never started, because you’ll assume your automations are running. Set up two simple checks.
An uptime monitor. n8n exposes a health endpoint at /healthz that returns 200 when the app is up. Point a free uptime monitoring service at https://n8n.yourdomain.com/healthz and have it email or message you when it fails. In our lab this endpoint answered as soon as n8n finished starting.
An error workflow. In n8n, create a workflow that starts with the Error Trigger node and sends you a message by email, Slack or Telegram. Then set it as the error workflow in each important workflow’s settings. You’ll hear about failed runs instead of finding out a week later.
Watch the disk. Execution history, binary files and Docker images all take space. Run df -h now and then, and docker image prune after updates to remove old images. Running out of disk is one of the most common reasons a self-hosted instance stops.
When one server isn’t enough
A single container handles far more than most people need: our 1-core test ran 10 requests at once without errors. If you outgrow it, n8n has a queue mode, where a main instance receives triggers and separate worker containers run the executions, coordinated through Redis.
You’ll know you need it when executions start queuing, webhook responses slow down noticeably, or one heavy workflow delays everything else. Before you switch, try the simpler fixes: a bigger server, splitting huge workflows into sub-workflows, and processing large data in batches. Queue mode adds Redis and more containers to maintain, so only move to it when you’ve measured the need.
Easier ways to self-host
If the Docker steps feel like too much, there are middle grounds between doing everything yourself and paying for Cloud:
- Provider templates. Hostinger and several other VPS providers offer n8n as a one-click install. You still own the server, but the initial setup is done for you.
- App platforms. Self-hosted panels like Coolify or Easypanel run on your VPS and install n8n from a template with HTTPS included. They also make updates a button click.
- Managed n8n hosts. Some hosting companies run n8n for you on dedicated resources, at a price between a raw VPS and n8n Cloud.
Whichever route you pick, check the same three things: where backups go, how you update, and whether you have the encryption key stored somewhere safe.
Self-hosted vs n8n Cloud: the real monthly bill
The self-hosted Community Edition is free, so your bill is the server plus your time. n8n Cloud bundles hosting, updates and backups, and charges by plan and execution count.
| Monthly executions | Self-hosted (2 to 4 GB VPS) | n8n Cloud |
|---|---|---|
| Up to 2,500 | $6 to $24 | Starter, $20 a month billed annually |
| Up to 10,000 | $6 to $24 | Pro, $50 a month billed annually |
| 50,000 | $6 to $24, maybe a bigger server | A higher Pro tier or Business |
| Unlimited | Limited only by your server | Enterprise, custom pricing |
The money gap is large. A 2 to 4 GB VPS costs $6 to $24 a month whether you run 100 executions or 100,000. Cloud Starter costs $20 a month billed annually and includes 2,500 executions; Pro is $50 a month for 10,000. At 10,000 executions a month, a $12 server instead of the Pro plan saves over $400 a year.
Your time is the hidden cost. Budget about 45 minutes for setup and an hour a month for updates and checks. If your time is worth more than the difference, Cloud is the better deal. Our breakdown of Make vs n8n vs Zapier pricing compares how executions are counted on each platform, and you can start a Cloud trial through n8n’s site.
Some features need a licence. The free self-hosted edition runs every workflow and node, but team features like SSO, environments and advanced permissions are part of n8n’s paid Business and Enterprise plans.

Troubleshooting common problems
| Symptom | Likely cause | Fix |
|---|---|---|
| “Could not establish database connection” in a loop | n8n can’t reach Postgres: wrong password, or a firewall blocking container traffic | Check DB_POSTGRESDB_* values match .env; check the server’s forwarding firewall rules |
| Browser shows a certificate error | DNS not pointing at the server yet, or ports 80 and 443 closed | Check the A record; allow 80 and 443 in ufw; read docker compose logs caddy |
| 502 Bad Gateway | n8n is still starting or has crashed | Wait 30 seconds; check docker compose logs n8n |
| Webhook URLs show localhost:5678 | N8N_WEBHOOK_URL or N8N_HOST not set | Set both to your real domain and restart |
| Production webhook returns 404 | Workflow not published, or wrong method | Publish the workflow; match GET or POST |
| Credentials fail after a restore | Different encryption key | Restore the original N8N_ENCRYPTION_KEY from your backup |
| Server runs out of memory | 1 GB RAM, or large files in workflows | Move to 2 GB or more; process files in smaller batches |
| Disk filling up | Execution history never deleted | Turn on EXECUTIONS_DATA_PRUNE and set a max age |
Read the logs first. Nearly every problem shows up in docker compose logs n8n or docker compose logs caddy. Our database error was obvious in the first line of n8n’s log; the fix just wasn’t in n8n.

What to build first
Once n8n is running, the fastest way to learn it is to build something useful. Our tutorial on building your first AI agent in n8n walks through a complete workflow, and the RAG chatbot tutorial shows how to answer questions from your own documents. Both run fine on the setup above.
Our verdict
Self-hosting n8n is worth it if you run more than a few thousand executions a month or need data on your own server, and you’re willing to spend an hour a month on upkeep. A 2 GB VPS from Hostinger, DigitalOcean or Contabo runs it comfortably, the setup takes under an hour, and in our test a full restore took 27 seconds.
If you’ve never used a Linux server and don’t want to learn, start on n8n Cloud. You can export your workflows and move to self-hosting later.
Heads-up: our Hostinger, DigitalOcean, Contabo and n8n links are affiliate links. If you buy through them, DroidCrunch earns a commission at no extra cost to you.
Is self-hosted n8n really free?
Yes. The Community Edition is free to run for your own workflows under n8n’s Sustainable Use License, with no execution limits. You pay for the server and spend your own time on upkeep. Some team features, such as SSO and environments, need a paid licence.
How much RAM does n8n need?
In our test n8n used about 406 MB at idle and 660 MB after a burst of webhook calls, with Postgres adding about 30 MB. A 1 GB server runs, but tightly. We recommend 2 GB as the minimum and 4 GB for workflows that handle large files or AI tasks.
Can I self-host n8n without Docker?
Yes. You can install it with npm on any machine with Node.js. Docker is easier to update, back up and move between servers, which is why n8n’s own guides use it. For a production server, we’d stick with Docker Compose.
Should I use SQLite or Postgres?
SQLite is the default and fine for testing or very light use. Postgres handles many executions better and can be backed up while n8n runs. Since adding it is one more block in the compose file, we use Postgres for any server that will run real workflows.
Can I move from n8n Cloud to self-hosted?
Yes. Export your workflows from Cloud and import them on your server. Credentials don’t transfer in usable form, because they’re encrypted with a different key, so you’ll re-enter API keys and reconnect OAuth accounts after the move.
How often should I update self-hosted n8n?
Once or twice a month is a sensible rhythm. You don’t need every weekly release, but security fixes arrive in them and big version jumps are riskier. Subscribe to n8n’s release notes or GitHub releases so you know when an update fixes something serious.
Is self-hosted n8n secure?
It can be. Keep n8n behind an HTTPS proxy, leave port 5678 closed, use two-factor authentication, update n8n and the server regularly, and protect sensitive webhooks with authentication. Most problems come from exposed ports and outdated versions, not from n8n itself.
Does Hostinger have a one-click n8n install?
Yes, Hostinger’s VPS plans offer an n8n template that installs it for you. It’s quicker than the manual setup, but you should still check where backups go, set up two-factor authentication and know how to update it.



