VPS for n8n Requirements at a Glance
The requirements of a VPS for n8n are modest on CPU and heavier on memory, because n8n holds workflow data in memory while it runs.
n8n runs all the time, so webhooks and schedules fire even when your computer is off. This guide sizes the server from measured numbers, then builds a complete Docker Compose deployment with PostgreSQL, Caddy for HTTPS, isolated task runners, tested backups and a tested rollback.
The n8n documentation gives an example range of 320 MB to 2 GB of memory and 512 MB to 4 GB of SSD for the database, based on n8n Cloud, and says memory usually matters more than CPU. A self-hosted stack with its own database needs more than an idle Cloud instance, so we measured the stack built in this guide with docker stats --no-stream.
| Container | Idle, 5 minutes after start | Highest of 12 samples during 200 webhook calls |
|---|---|---|
| n8n main process | 347 MiB | 400 MiB |
| Task runners (Python and JavaScript) | 9 MiB | 218 MiB |
| PostgreSQL 18.7 | 63 MiB | 61 MiB |
| Caddy 2.11.9 | 12 MiB | 14 MiB |
| Whole stack | about 430 MiB | about 690 MiB in the busiest sample |
The load test sent 200 POST requests, 10 at a time, to a webhook workflow that runs one Python and one JavaScript Code node. All 200 returned 200 in 41.8 seconds. During the run docker stats --no-stream was sampled 12 times back to back, and the table keeps the highest value per container, so a short spike between samples could be missed. These figures cover the containers only, not Ubuntu, Docker itself or anything else on the server, and they are one small workflow, not a benchmark of yours.
| Plan size | Fits | Watch out for |
|---|---|---|
| 1 vCPU and 1 GB RAM | Trying n8n out | The containers alone reached about 690 MiB in our load test, before the OS, so little headroom is left |
| 1 to 2 vCPU and 2 GB RAM | One person with light scheduled workflows | Big files, large API pages and long manual runs |
| 2 vCPU and 4 GB RAM | The safer production start, small teams, many webhooks | Execution history growth in PostgreSQL |
| 4 vCPU and 8 GB RAM or more | Heavy data, AI agents, several busy workflows | Plan queue mode before one process is the limit |
For disk, 20 GB is a workable minimum and 40 GB of SSD or NVMe is a better production start. docker system df counted about 3.9 GB for the four images in use, an update keeps the old image until you prune it, and execution history and binary files grow over time. Keep backups on separate storage, not only on the same disk.
How Workflow Size and Concurrency Affect RAM
Workflow size and concurrency drive RAM far more than idle use does, because each running execution holds its data in memory.
A workflow that pulls 10,000 rows at once needs much more memory than one that loops over pages of 200. The Compose file below caps production executions at 5 at a time with N8N_CONCURRENCY_PRODUCTION_LIMIT, which n8n leaves off by default. Extra runs wait in a queue instead of all loading at once. The cap does not apply to manual runs from the editor.
How to Choose a VPS for n8n
To choose a VPS for n8n, check root access, memory, disk type and network before price, because those decide how reliably workflows run.
| Check | Why it matters for n8n |
|---|---|
| A real VPS with root access, not shared hosting | Docker and long running processes are needed |
| Docker support and the kernel features it needs | Avoid plans that restrict Docker, its networking or required kernel features |
| RAM from the sizing table | Memory is the first limit n8n hits |
| SSD or NVMe disk | PostgreSQL writes execution history all the time |
| A stable public IP address | DNS and webhook delivery stay reliable, and a static IPv4 address is the simplest option |
| A location near the APIs you call | Shorter round trips for every HTTP request node |
| Snapshots or a provider backup option | A second safety net next to your own backups |
| Bandwidth allowance | File heavy workflows move a lot of data |
Shared vCPU plans are usually fine, since n8n is rarely CPU bound. Dedicated cores help when several heavy Code nodes run at once. If you want a server already sized for this, see our n8n VPS hosting plans.
Self-Hosted n8n or n8n Cloud
Self-hosted n8n gives you full control of data and limits, while n8n Cloud takes the server work off your hands.
| Area | Self-hosted on a VPS | n8n Cloud |
|---|---|---|
| Server updates and security | Your job | Handled by n8n |
| Backups and restores | Your job, as shown below | Handled by n8n |
| Where data lives | On your server | On n8n infrastructure |
| Limits | Set by your hardware and settings | Set by your plan |
| Cost | The server plus your time | A subscription |
n8n itself suggests Cloud for people without server administration experience. A VPS is cheaper only when you count your maintenance time as acceptable.
The free self-hosted edition uses the Sustainable Use License. Its license FAQ allows internal use and building workflows for clients on your own instance, as long as clients cannot create or edit them. Hosting n8n so customers build their own workflows, or white-labelling it, needs a commercial license.
What You Need Before You Start
Before you start, you need a 64-bit Ubuntu 22.04 or 24.04 server with sudo access and a domain you control.
Keep a way into the provider console in case SSH breaks. Create a DNS A record for a subdomain, such as n8n.example.com, pointing at the server address. Add an AAAA record only if the server really accepts IPv6 traffic on ports 80 and 443, because a wrong AAAA record can break certificate issuance even when the A record is right.
This guide uses n8n.example.com and 203.0.113.10 as documentation examples, so replace them with your own name and address.
How the Self-Hosted n8n Stack Fits Together
The self-hosted n8n stack has four containers, and only one of them faces the internet.
- Caddy on ports 80 and 443A reverse proxy that gets a certificate, redirects HTTP to HTTPS and passes requests to n8n.
- n8n on port 5678The editor, webhooks and scheduler. Reachable from Caddy on the private Docker network and from the server itself on 127.0.0.1 only.
- Task runnersA separate container that executes Code node tasks outside the main n8n process.
- PostgreSQL on port 5432Stores workflows, credentials and execution history. Not published at all.
n8n recommends PostgreSQL for production and a reverse proxy in front instead of exposing n8n directly. Its task runner guide calls the built-in internal mode insecure by design and asks for external runners in production, which is why they get their own container here. External runners give process isolation, not a complete security boundary, and anyone who can edit workflows can still run code through Code nodes.
The official n8n Compose example uses Traefik. This guide uses Caddy because its config is two lines, and the n8n settings are the same either way.
Install Docker Engine and Docker Compose
Install Docker Engine and Docker Compose from the Docker apt repository, which Docker documents for Ubuntu 22.04, 24.04 and 26.04.
sudo apt update
sudo apt install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginCheck that both tools answer. These are the versions on the test machine.
docker --version
docker compose versionDocker version 29.9.3, build 5457199
Docker Compose version v5.7.0This guide uses the Compose plugin, called as docker compose with a space. Older guides use the separate docker-compose program, which the Docker repository above does not install.
Create the n8n Folder and Secrets
Create the n8n folder in /opt/n8n and write a .env file that holds the version, the domain and three random secrets.
sudo mkdir -p /opt/n8n
sudo chown "$(id -un)": /opt/n8n
cd /opt/n8n
(umask 077; cat > .env <<EOF
N8N_DOMAIN=n8n.example.com
N8N_VERSION=2.49.7
GENERIC_TIMEZONE=UTC
POSTGRES_USER=n8n
POSTGRES_PASSWORD=$(openssl rand -hex 24)
POSTGRES_DB=n8n
N8N_ENCRYPTION_KEY=$(openssl rand -hex 32)
N8N_RUNNERS_AUTH_TOKEN=$(openssl rand -hex 32)
EOF
)
ls -l .envPin N8N_VERSION to a real release number instead of latest, so an image pull never upgrades n8n behind your back. 2.49.7 was the stable release when this was tested, so check the n8n release notes for the current one.
Write the Docker Compose File for n8n
Save this Docker Compose file as /opt/n8n/compose.yaml. It is the exact file used in the test.
services:
caddy:
image: caddy:2.11.9
restart: unless-stopped
ports:
- "${HTTP_PORT:-80}:80"
- "${HTTPS_PORT:-443}:443"
- "${HTTPS_PORT:-443}:443/udp"
environment:
- N8N_DOMAIN=${N8N_DOMAIN}
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile:ro
- caddy_data:/data
- caddy_config:/config
depends_on:
- n8n
n8n:
image: docker.n8n.io/n8nio/n8n:${N8N_VERSION}
restart: unless-stopped
ports:
- "127.0.0.1:${N8N_LOCAL_PORT:-5678}:5678"
environment:
- N8N_HOST=${N8N_DOMAIN}
- N8N_PORT=5678
- N8N_LISTEN_ADDRESS=0.0.0.0
- N8N_PROTOCOL=https
- N8N_PROXY_HOPS=1
- N8N_WEBHOOK_URL=https://${N8N_DOMAIN}/
- N8N_EDITOR_BASE_URL=https://${N8N_DOMAIN}/
- N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}
- N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
- NODE_ENV=production
- GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
- TZ=${GENERIC_TIMEZONE}
- DB_TYPE=postgresdb
- DB_POSTGRESDB_HOST=postgres
- DB_POSTGRESDB_PORT=5432
- DB_POSTGRESDB_DATABASE=${POSTGRES_DB}
- DB_POSTGRESDB_USER=${POSTGRES_USER}
- DB_POSTGRESDB_PASSWORD=${POSTGRES_PASSWORD}
- EXECUTIONS_DATA_PRUNE=true
- EXECUTIONS_DATA_MAX_AGE=168
- N8N_CONCURRENCY_PRODUCTION_LIMIT=5
- N8N_RUNNERS_MODE=external
- N8N_RUNNERS_BROKER_LISTEN_ADDRESS=0.0.0.0
- N8N_RUNNERS_AUTH_TOKEN=${N8N_RUNNERS_AUTH_TOKEN}
volumes:
- n8n_data:/home/node/.n8n
depends_on:
postgres:
condition: service_healthy
task-runners:
image: n8nio/runners:${N8N_VERSION}
restart: unless-stopped
environment:
- N8N_RUNNERS_TASK_BROKER_URI=http://n8n:5679
- N8N_RUNNERS_AUTH_TOKEN=${N8N_RUNNERS_AUTH_TOKEN}
depends_on:
- n8n
postgres:
image: postgres:18.7
restart: unless-stopped
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
volumes:
- pg_data:/var/lib/postgresql
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
interval: 10s
timeout: 5s
retries: 5
volumes:
n8n_data:
pg_data:
caddy_data:
caddy_config:The port lines read optional variables and fall back to 80, 443 and 5678 when they are not set. The test set them to other numbers because other services share that machine, so leave them out of .env on your own server.
| Variable | Value here | Why |
|---|---|---|
N8N_HOST and N8N_PROTOCOL | your domain, https | n8n builds its own links from these |
N8N_WEBHOOK_URL | https://n8n.example.com/ | Webhook nodes show this public address instead of localhost |
N8N_PROXY_HOPS | 1 | Tells n8n one proxy sits in front, so it trusts the forwarded client address |
N8N_LISTEN_ADDRESS | 0.0.0.0 | The default is ::, which failed in a container without IPv6 |
N8N_ENCRYPTION_KEY | from .env | Without it n8n makes a random key you must find and save yourself |
EXECUTIONS_DATA_MAX_AGE | 168 hours | Prunes execution history after 7 days instead of the default 14 |
N8N_CONCURRENCY_PRODUCTION_LIMIT | 5 | Queues extra production runs instead of loading them all at once |
N8N_RUNNERS_MODE | external | Runs Code node code in the separate runners container |
The runners image version must match the n8n version, which is why both read N8N_VERSION. There is no N8N_RUNNERS_ENABLED line, because n8n 2.49.7 logged that this variable is no longer needed when we set it. Keep the runners image updated with n8n, and do not mount host folders into it. N8N_WEBHOOK_URL replaced WEBHOOK_URL in recent 2.x releases, so use WEBHOOK_URL only on an older version. The pruning defaults come from the n8n execution data guide.
Configure Caddy as the HTTPS Reverse Proxy
Caddy as the HTTPS reverse proxy needs one site block, saved as /opt/n8n/Caddyfile next to the Compose file.
{$N8N_DOMAIN} {
reverse_proxy n8n:5678
}Caddy reads the domain from the environment, requests a certificate and renews it on its own. That only works when DNS already points at the server and ports 80 and 443 are reachable from the internet. The certificate is kept in the caddy_data volume, so it survives restarts.
The reverse_proxy directive sets X-Forwarded-For, X-Forwarded-Proto and X-Forwarded-Host for you, and it ignores those headers when a client sends them, which stops spoofing.
The test machine had no public DNS name, so its Caddyfile carried one extra line, tls internal, which makes Caddy sign its own certificate. That tested the proxy and HTTPS handling, not public certificate issuance or renewal. Leave the line out on a real server.
Start n8n and Check It Is Healthy
Start n8n from the project folder, then check the containers, the health endpoints and the logs before you open the browser.
cd /opt/n8n
sudo docker compose up -d
sudo docker compose psThis is the real output from the test. Caddy shows ports 18080 and 18443 because of the test port variables, and on your server they read 80 and 443.
NAME IMAGE STATUS PORTS
n8n-caddy-1 caddy:2.11.9 Up 44 minutes 2019/tcp, 0.0.0.0:18080->80/tcp, 0.0.0.0:18443->443/tcp, 0.0.0.0:18443->443/udp
n8n-n8n-1 docker.n8n.io/n8nio/n8n:2.49.7 Up 5 minutes 127.0.0.1:15678->5678/tcp
n8n-postgres-1 postgres:18.7 Up 54 minutes (healthy) 5432/tcp
n8n-task-runners-1 n8nio/runners:2.49.7 Up 8 minutes 5680/tcpCheck that postgres says healthy and that port 5678 is bound to 127.0.0.1 only. Then ask n8n itself, first locally and then through Caddy.
curl -s -w ' %{http_code}\n' http://127.0.0.1:5678/healthz
curl -s -w ' %{http_code}\n' http://127.0.0.1:5678/healthz/readiness
curl -s -o /dev/null -w '%{http_code} HTTP/%{http_version}\n' https://n8n.example.com/healthz/readiness{"status":"ok"} 200
{"status":"ok"} 200
200 HTTP/2The test sent the same requests to its own ports, with curl told to resolve the example domain to the test machine. /healthz answers as soon as the web server is up and says nothing about the database. /healthz/readiness returns 200 only once the database is connected and migrated, and the last line shows HTTPS through Caddy works.
The logs confirm the version, the task broker for the runners and the public address n8n will use.
sudo docker compose logs n8n --no-log-prefix | grep -E 'ready on|^Version:|accessible via' -A1n8n ready on 0.0.0.0, port 5678
Acquiring database migration lock...
n8n Task Broker ready on 0.0.0.0, port 5679
--
Version: 2.49.7
Building workflow dependency index...
--
Editor is now accessible via:
https://n8n.example.comNone of these checks proves your workflows run. In the test, a published webhook workflow with a Python Code node and a JavaScript Code node answered through Caddy.
curl -s -X POST https://n8n.example.com/webhook/runner-test{"py_sum":5050,"doubled":10100}Secure the Self-Hosted n8n Server
Secure the self-hosted n8n server with a firewall that allows SSH, HTTP and HTTPS only. Allow SSH first, or enabling ufw can cut your session.
sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 443/udp
sudo ufw enable
sudo ufw status verboseUDP 443 is only for HTTP/3 and can stay closed. On Ubuntu, /etc/default/ufw ships with IPV6=yes, so these rules cover IPv4 and IPv6. If your provider has its own cloud firewall, apply the same rules there and never open TCP 5432 or 5678 to the internet.
Docker has a catch here. Its documentation warns that ports published by Docker bypass ufw rules, so a 5678:5678 line would expose n8n even with ufw blocking it. That is why the Compose file publishes 5678 on 127.0.0.1 only. Confirm what is really listening with ss.
sudo ss -ltnu | grep -E ':(80|443|5678)\b'The test machine used its own port numbers, so the same check there filtered for 18080, 18443 and 15678 and returned this.
udp UNCONN 0 0 0.0.0.0:18443 0.0.0.0:*
tcp LISTEN 0 4096 0.0.0.0:18080 0.0.0.0:*
tcp LISTEN 0 4096 0.0.0.0:18443 0.0.0.0:*
tcp LISTEN 0 4096 127.0.0.1:15678 0.0.0.0:*The n8n port listens on the loopback address only, and a request to the server public address on that port was refused. A firewall limits who can connect. It does not protect a weak password or a risky workflow, so add these habits.
- Use SSH keys and turn off password sign in for SSH.
- Apply Ubuntu, Docker and n8n updates on a schedule.
- Invite only the people who need an n8n account.
- Install community nodes only from sources you trust.
- Protect production webhooks with header or basic authentication where the caller supports it.
n8n also has a built-in security audit. Run sudo docker compose exec -u node n8n n8n audit. In the test it flagged the unused test credential and three risky nodes, the HTTP Request node and the two Code nodes, and showed that 2.49.7 excludes the Execute Command node by default.
Keep n8n Data Persistent in Docker Volumes
n8n data stays persistent because each container writes to a named Docker volume, not to the container itself.
| Volume | Holds | If you lose it |
|---|---|---|
n8n_pg_data | Workflows, credentials, users, execution history | Everything you built is gone |
n8n_n8n_data | The config file with the encryption key, event logs | Credentials cannot be decrypted unless the key is in .env |
n8n_caddy_data | TLS certificates and keys | Caddy requests new certificates |
n8n_caddy_config | Caddy runtime config | Nothing important |
The n8n_ prefix comes from the folder name, so a different folder gives different volume names. docker compose down keeps volumes, while docker compose down -v deletes them, so treat -v as a delete command.
In the test, the PostgreSQL volume was about 77 MB with two small workflows, mostly the empty database itself. It grows with execution history, which is why the Compose file prunes it.
Back Up n8n Every Night
Back up n8n every night with one script that dumps PostgreSQL, archives the n8n volume, checks both files and exports workflows.
Save it as /usr/local/sbin/n8n-backup.sh and make it executable with chmod 700. Each run goes to a dated folder only root can read, and folders older than 14 days are deleted.
#!/usr/bin/env bash
set -euo pipefail
APP_DIR="${APP_DIR:-/opt/n8n}"
BACKUP_DIR="${BACKUP_DIR:-/opt/n8n-backups}"
KEEP_DAYS="${KEEP_DAYS:-14}"
cd "$APP_DIR"
umask 077
DEST="$BACKUP_DIR/$(date +%Y%m%d-%H%M%S)"
mkdir -p "$DEST"
docker compose exec -T postgres sh -c 'pg_dump -U "$POSTGRES_USER" -d "$POSTGRES_DB" -Fc' > "$DEST/n8n-db.dump"
docker compose exec -T n8n tar czf - -C /home/node/.n8n . > "$DEST/n8n-data.tgz"
cp .env compose.yaml Caddyfile "$DEST/"
test -s "$DEST/n8n-db.dump"
test -s "$DEST/n8n-data.tgz"
docker compose exec -T postgres pg_restore --list < "$DEST/n8n-db.dump" > /dev/null
tar -tzf "$DEST/n8n-data.tgz" > /dev/null
if docker compose exec -T -u node n8n sh -c 'rm -rf /tmp/n8n-export && mkdir -p /tmp/n8n-export/workflows /tmp/n8n-export/credentials && n8n export:workflow --backup --output=/tmp/n8n-export/workflows/ && n8n export:credentials --backup --output=/tmp/n8n-export/credentials/' > "$DEST/export.log" 2>&1; then
docker compose cp n8n:/tmp/n8n-export "$DEST/cli-export" > /dev/null 2>&1
else
echo "CLI export failed, see $DEST/export.log (database and volume backups are complete)"
fi
chmod -R go-rwx "$DEST"
find "$BACKUP_DIR" -mindepth 1 -maxdepth 1 -type d -mtime +"$KEEP_DAYS" -exec rm -rf {} +
echo "Backup written and checked: $DEST"
du -sh "$DEST"The script stops with an error if the dump or the archive is empty or unreadable. The workflow and credential export is a readable second copy, and its failure does not stop the script, because n8n returns an error when there are no credentials to export. The test set APP_DIR and BACKUP_DIR to its own folders.
Backup written and checked: /root/w/self-host-n8n-vps/backups/20261127-021019
872K /root/w/self-host-n8n-vps/backups/20261127-021019These checks prove the files can be read, not that n8n can start from them, so test a restore as shown next. Schedule the script with cron, for example at 03:15 every night.
echo '15 3 * * * root /usr/local/sbin/n8n-backup.sh >> /var/log/n8n-backup.log 2>&1' | sudo tee /etc/cron.d/n8n-backupThe folder holds .env with the database password and the encryption key, so copy it encrypted to storage off the server. A backup on the same disk does not survive a lost server. Watch its size with du -sh /opt/n8n-backups as execution history grows.
Restore n8n From a Backup
To restore n8n from a backup, copy the saved config files into /opt/n8n, then recreate the database and load the volume.
The config files are .env, compose.yaml and Caddyfile. Point B at the backup folder you want, and restore with the same PostgreSQL major version the dump came from.
cd /opt/n8n
B=/opt/n8n-backups/20261127-021019
sudo docker compose stop n8n task-runners
sudo docker compose up -d postgres
sudo docker compose exec -T postgres sh -c 'dropdb -U "$POSTGRES_USER" --force "$POSTGRES_DB" && createdb -U "$POSTGRES_USER" "$POSTGRES_DB"'
sudo docker compose exec -T postgres sh -c 'pg_restore -U "$POSTGRES_USER" -d "$POSTGRES_DB" --no-owner --exit-on-error' < "$B/n8n-db.dump"
sudo docker compose create n8n
sudo docker compose run --rm --no-deps -T --entrypoint sh n8n -c 'tar xzf - -C /home/node/.n8n' < "$B/n8n-data.tgz"
sudo docker compose up -dIn the test, these exact commands restored the backup into a second, empty stack. The restored instance passed the readiness check, listed both test workflows and decrypted the test credential.
{"status":"ok"} 200
Lw3HkQp9aXc2Rt1m|Uptime ping
Wh7TestPyJs0001|Webhook code testThe same test with a different N8N_ENCRYPTION_KEY stopped n8n at start with this error, which is what you see when the key from .env was lost or mistyped.
UserError: Mismatching encryption keys. The encryption key in the settings file /home/node/.n8n/config does not match the N8N_ENCRYPTION_KEY env var. Please make sure both keys match.When the recovered server works, point the DNS record at it and wait for the old record to expire before you shut the old one down.
Update and Roll Back n8n Safely
Update n8n safely by reading the release notes, taking a backup and then changing only the pinned version number.
sudo /usr/local/sbin/n8n-backup.sh
cd /opt/n8n
sudo sed -i 's/^N8N_VERSION=.*/N8N_VERSION=NEW_STABLE_VERSION/' .env
sudo docker compose pull
sudo docker compose up -d
sudo docker compose psReplace NEW_STABLE_VERSION with the current stable release. The test moved a copy from 2.49.7 to 2.50.2, which was a beta at the time and was used only because it was newer. The new version ran database migrations at start, such as CreateLeaseTables1794906454000.
Roll Back After a Bad Update
To roll back after a bad update, restore the backup taken before it, because n8n does not undo its database migrations.
In the test, simply setting the old version back started 2.49.7 on the migrated database, with the newer tables still in it. A plain pg_restore --clean left those tables behind too and ignored 29 errors. Recreating the database first, as in the restore commands above, gave a clean result.
- Set the old versionPut the previous
N8N_VERSIONback in.env. - Restore the pre-update backupRun the restore commands with
Bpointing at the backup taken before the update. - Check itConfirm readiness returns 200, your workflows are listed and a credential still works.
After the rollback in the test, readiness returned 200, both workflows were listed and the table added by 2.50.2 was gone. Update Caddy and PostgreSQL minor versions the same way. A PostgreSQL major version change, such as 18 to 19, cannot reuse the old data files, so plan it as a dump and restore with a verified backup.
Monitor n8n and Know When to Upgrade the VPS
Monitor n8n with a few commands, and upgrade the VPS when memory stays high, containers restart or the disk keeps filling.
free -h
df -h /
sudo docker stats --no-stream
sudo docker inspect -f '{{.Name}} OOMKilled={{.State.OOMKilled}} Restarts={{.RestartCount}}' $(sudo docker compose ps -q)
sudo dmesg -T | grep -E 'Out of memory|oom-kill|Killed process'free -h shows host memory and swap. df -h shows disk space. docker stats shows memory per container. The inspect line shows whether Docker killed a container for memory and how often it restarted, and in the test every container showed OOMKilled=false Restarts=0.
The dmesg filter matches only kernel out of memory events. A looser filter on just oom matched an unrelated oom_control notice on the test machine. No output means no such event is left in the kernel message buffer, which is finite, so keep persistent system logs for longer history.
Upgrade to the next plan size when memory stays near the limit, a container shows OOMKilled=true, executions get slower as more run at once or PostgreSQL keeps growing after pruning. Before buying more RAM, check whether a workflow can process data in smaller batches.
When n8n Queue Mode Makes Sense
n8n queue mode makes sense when one n8n process cannot keep up, not as a default for a small server.
In queue mode, the main instance receives triggers and webhooks, Redis passes executions on, and separate worker processes run them. It needs PostgreSQL, every worker needs the same encryption key, and file based binary data must sit on storage that all processes share.
Adding Redis alone does not make n8n faster. The gain comes from workers spread over more CPU and memory. Most single VPS setups are better served first by the concurrency cap, smaller batches and a larger plan.
Fix Common n8n VPS Problems
Most n8n VPS problems show up in docker compose logs n8n, so read the first error line and match it below.
| What you see | Cause | Fix |
|---|---|---|
address '::' is not available and a restart loop | No IPv6 inside the container | Set N8N_LISTEN_ADDRESS=0.0.0.0 |
| Caddy returns 502 for a few seconds | n8n is still starting | Wait for the readiness check to return 200 |
Mismatching encryption keys | The key in .env differs from the saved config | Put back the original key |
| Webhook URLs show localhost:5678 | N8N_WEBHOOK_URL is missing | Set it to your HTTPS address and recreate the container |
| Browser warns about the certificate | DNS not pointing at the server, a wrong AAAA record or port 80 blocked | Fix DNS and the firewall, then restart Caddy |
No matching task offer or Code nodes hang | The runners container is down or its token differs | Check docker compose logs task-runners and the shared token |
process is not defined in a Code node | Code nodes run in a sandbox without Node.js globals | Use n8n data helpers instead of process |
| Container restarts during big runs | Out of memory | Process smaller batches, lower concurrency or add RAM |
Both runner errors were seen in the test. The first appeared for a few seconds while the runners reconnected after an n8n restart, and the second came from a test node that read process.
For a clean Ubuntu server to run all of this on, a Docker VPS with root access works the same way as the setup above.
Questions people ask
How much RAM does n8n need on a VPS?
Plan for 2 GB for light use and 4 GB for production. Our full stack idled near 430 MiB and reached about 690 MiB in a small load test.
Is 4 GB RAM enough for n8n?
For most single servers, yes. It leaves room for PostgreSQL, the OS and bursts, unless workflows load large files or datasets at once.
Do I need PostgreSQL or is SQLite enough?
SQLite works for testing. n8n recommends PostgreSQL for production, and queue mode does not support SQLite.
Does n8n need Redis?
Not on a single server. Redis is only needed for queue mode, where separate workers run executions.
Can I use self-hosted n8n for client work?
Yes, if you build and run the workflows and clients cannot create or edit them. Letting customers build workflows needs a commercial license.
Is a VPS better than n8n Cloud?
A VPS gives control of the server and avoids Cloud plan quotas, but you handle updates, security and backups. The self-hosted license and feature limits still apply.
What happens if I lose the n8n encryption key?
Saved credentials can no longer be decrypted. Workflows survive, but you must enter every credential again.
Why do my n8n webhook URLs show localhost?
n8n does not know its public address. Set N8N_WEBHOOK_URL to your HTTPS URL and recreate the container.
Sources
- n8n Docs, Production requirements
- n8n Docs, Prerequisites with example sizing
- n8n Docs, Self-hosting n8n with Docker Compose
- n8n Docs, Deployment environment variables
- n8n Docs, Set up task runners
- n8n Docs, Backup and restore
- n8n Docs, Monitor n8n and health endpoints
- Caddy documentation, reverse_proxy directive
- Docker Docs, Install Docker Engine on Ubuntu