How to Self-Host n8n on a VPS: Docker Compose, Postgres, Pruning and Queue Mode
Self-hosting n8n is straightforward until the disk fills or one process stops keeping up. Here is the Docker Compose setup, the Postgres switch, pruning, and when queue mode is worth it.
You can self-host n8n on a VPS with Docker Compose in about an hour: point a subdomain at the server, run n8n behind a reverse proxy with HTTPS, switch from the default SQLite database to Postgres, set execution pruning, and only move to queue mode with Redis and workers when one process can no longer keep up. For a small team, a 2 vCPU / 4 GB server is a sensible starting point; production use with many executions deserves more memory for Postgres.
Why self-host n8n at all
n8n connects your CRM, billing, email and chat tools, which means it holds API keys and credentials for all of them. Running it on a server you control keeps workflows, credentials and execution history under your own access rules. The trade-off is that the security and upkeep of that one server become your job. n8n's own documentation says plainly that self-hosting needs technical knowledge of servers, containers, scaling and security, and that mistakes can lead to data loss, security issues and downtime. If nobody on your team is comfortable with that, think twice, or agree managed administration in writing, because VPSWala plans are unmanaged by default.
Step 1: pick a server
VPSWala's n8n hosting page lists three starting points, in monthly rupees excluding GST. They are suggestions, not guarantees, and the page itself says to move up when you measure pressure rather than because a page told you to:
| Use | Plan | Specification | Monthly |
|---|---|---|---|
| Personal or small-team workflows | VPS 4 | 2 vCPU, 4 GB RAM, 40 GB NVMe | Rs 596 |
| Production automation, many executions | VPS 16 | 6 vCPU, 16 GB RAM, 160 GB NVMe | Rs 2,399 |
| Queue mode with several workers | VPS 32 | 12 vCPU, 32 GB RAM, 320 GB NVMe | Rs 4,799 |
Every plan comes with full root access and a choice of Mumbai, Noida or Jaipur nodes. Pick the node nearest the services your workflows call most often.
Step 2: install Docker and write the Compose file
n8n documents a Docker Compose setup for a Linux server. The outline is: install Docker Engine and the Compose plugin, create a project directory, add an .env file with your domain, subdomain, timezone and an email address for certificates, create a local files directory, then write a compose.yaml. Their example runs two containers, n8n and Traefik, where Traefik handles HTTPS certificates and routing. It also mounts two named volumes, one for n8n's data directory at /home/node/.n8n and one for Traefik's certificate store, plus a bind mount for shared files. Start it with docker compose up -d and stop it with docker compose stop.
Create an A record for your chosen subdomain pointing at the server's IP address before you start, because certificate issuance needs DNS to resolve. Webhooks from most SaaS tools will not accept a self-signed certificate, so plan the domain and certificate before you migrate any workflow, not after.
Step 3: keep it running after a reboot
Docker's documentation recommends restart policies over process managers for starting containers automatically. With unless-stopped, Docker restarts a container if it exits or if the daemon restarts, but not if you stopped it yourself. A restart policy only takes effect after a container has been up for at least ten seconds, which stops a container that cannot start from looping forever. n8n's own example uses restart: always; either is reasonable, but know the difference before a maintenance window.
Step 4: stop the disk filling with execution data
Execution history is what grows. n8n's documentation says to avoid saving unnecessary data and to enable pruning. Pruning is on by default, and it removes finished executions either when they are older than EXECUTIONS_DATA_MAX_AGE (default 336 hours, which is 14 days) or when the total count exceeds EXECUTIONS_DATA_PRUNE_MAX_COUNT (default 10,000), deleting oldest first. You can also save only failed executions by setting EXECUTIONS_DATA_SAVE_ON_SUCCESS to none. Decide your retention window now; it is much easier than clearing a full disk later.
Step 5: move to Postgres before you rely on it
New installs default to SQLite stored in the data volume. That is fine for testing, but n8n says running queue mode on SQLite is not recommended, and a distributed setup over SQLite is not supported. Switching to Postgres early means you will not need a risky data migration when you grow. Give Postgres real memory on busier servers.
Step 6: queue mode, only when you need it
Queue mode splits n8n into a main instance, which receives triggers and webhooks, and worker instances, which run the executions. Redis holds the queue of pending executions and the database stores the results. n8n's documentation describes the setup: set EXECUTIONS_MODE to queue on the main instance and each worker, point them at Redis with QUEUE_BULL_REDIS_HOST and the related variables, share the same encryption key with every worker so they can read stored credentials, and start workers with the worker command. Workers can optionally expose health check endpoints. For heavy webhook traffic you can add separate webhook processors behind a load balancer, but n8n advises against putting the main process in that pool.
Queue mode adds moving parts, so use it when one process is the measured bottleneck. If you do, the VPS 32 class of server gives workers their own cores.
Day-one security checklist
- Back up the encryption key separately from the database; without it, stored credentials cannot be read.
- Keep n8n's port bound to localhost and let the proxy handle public traffic, as the Compose example does.
- Allow only ports 80, 443 and SSH through the firewall.
- Arrange off-server backups; they are not included in the plan.
Next step
See current sizes and prices on the cloud VPS page, read the n8n hosting page for the sizing table above, or compare options on VPS vs dedicated. Plans start at Rs 149 per month excluding GST. If you want a specific recommendation for your workflows, talk to VPSWala.
Sources
Not sure which size?
Send the stack, get a size.
Tell us the operating system, application stack, current traffic, database size and where it hurts today. You get a sizing recommendation, the matching plan and a price.
Related
Windows RDP VPS Server in Udaipur, Rajasthan: Remote Desktop Hosting for Hotels, Marble Traders and Colleges
A Windows RDP VPS gives Udaipur hotels, marble traders and college offices one remote desktop for accounts and admin software. Here is how to plan the node, licences, sizing and security.
VPS Backup Automation with rsync: Hard-Link Snapshots, a Restricted SSH Key and Cron
rsync with --link-dest gives you daily snapshots that look like full copies but only store changed files. Here is a pull-based setup with a locked-down SSH key and a cron schedule.
Magento VPS Performance: Varnish Full Page Cache, Redis Sessions and Separate Cache Databases
Most Magento speed on a VPS comes from caching layers, not raw CPU. This guide sets up Varnish for full page cache and Redis for sessions and default cache, using Adobe's documented commands.