buildwithdew
Tutorials·8 min read·August 14, 2026

n8n VPS Setup for a Lean Automation Stack

TL;DR

A lean n8n VPS setup in 2026 is best built with Docker Compose, PostgreSQL, and a reverse proxy on a small Linux VPS. Start with 2 vCPU and 4 GB RAM if you want room for growth, keep port 5678 off the public internet, and put HTTPS, DNS, environment variables, and backups in place from day one.

two anchored spheres joined by a narrow luminous bridge — centered vertical flow — calm resilient — cover for: n8n VPS Setup for a Lean Automation Stack

Key takeaways

  • Use Docker Compose, PostgreSQL, and a reverse proxy for the cleanest lean n8n stack.
  • Treat 2 vCPU / 4 GB RAM as the safer default for a low-cost production VPS.
  • Keep port 5678 private; expose only 80 and 443 through the proxy and firewall.
  • Set WEBHOOK_URL, N8N_HOST, N8N_PROTOCOL=https, and N8N_ENCRYPTION_KEY early.
  • Use DNS plus Let’s Encrypt before you rely on real webhooks or external callbacks.

If you want an n8n vps setup that is cheap, durable, and not overbuilt, the current best practice is a small Linux VPS running Docker Compose, PostgreSQL, and a reverse proxy that terminates HTTPS.12 In 2026, the lean-stack version of this usually means one VPS, one database, one proxy, and no public exposure of n8n’s internal port.34

What is the best n8n vps setup for a lean automation stack?

The best n8n vps setup is a Docker Compose deployment on a Linux VPS with n8n and PostgreSQL on a private network, fronted by Nginx, Caddy, or Traefik for HTTPS.12 That architecture is the most consistent recommendation across current guides because it keeps the workflow engine stable, the database persistent, and the public surface area small.124

For professionals and solopreneurs, the practical goal is not “run n8n somewhere” but “run it predictably enough that automations do not break at odd hours.” Current 2026 tutorials frame self-hosting as a way to avoid SaaS pricing while keeping control of workflows, credentials, and updates.34 The lean-stack thesis is simple: if the automation layer is essential, it should live on infrastructure you can inspect, back up, and restart without waiting for a vendor ticket.34

A useful way to think about the stack is:

LayerRecommended choiceWhy it matters
ComputeSmall Linux VPSLow cost, full control
RuntimeDockerRepeatable deployment
OrchestrationDocker ComposeEasy multi-container management
DatabasePostgreSQLDurable persistence
Public accessNginx, Caddy, or TraefikHTTPS and routing
NetworkPrivate Docker networkKeeps services isolated

That table reflects the pattern repeated in recent VPS tutorials: n8n in a container, PostgreSQL in a container, and a proxy in front of both.127 It is also the cleanest structure if you want one automation layer that can survive a VPS reboot, a proxy restart, or a routine update without drifting into fragile manual configuration.13

How much server do you need for n8n vps setup?

A safer low-cost baseline is 2 vCPU and 4 GB RAM, while 2 GB RAM can work for lighter workloads if you avoid queue-heavy or AI-heavy nodes.567 One 2026 guide states the minimum as “2 vCPUs and 4GB of RAM,” while another says “2GB RAM minimum (4GB if you run queue mode, Puppeteer or heavy AI nodes).”56

That difference is not a contradiction so much as a workload split. If you only need a few scheduled workflows, simple API syncs, and webhook handling, 2 GB may be enough to start.67 If you expect browser automation, larger payloads, or multiple concurrent executions, 4 GB is the more reliable floor.56

A practical sizing guide looks like this:

  • 2 vCPU / 4 GB RAM: best default for most small production stacks.56
  • 2 vCPU / 2 GB RAM: acceptable for light use and careful tuning.67
  • More than 4 GB RAM: useful if you add heavy AI nodes, queue mode, or more workflows over time.67

Recent guides also describe the setup as fast to complete once the VPS, Docker, DNS, and proxy pieces are ready; one 2026 tutorial says the process can be finished in 15–30 minutes.8 Cost framing is similarly restrained: one guide estimates roughly $4–12/month for the server and $0 for n8n itself.9

What should you install first on the VPS?

You should start with SSH access, a non-root user, firewall rules, Docker, and Docker Compose before you touch n8n itself.71015 The broader tutorial pattern is consistent: harden the server first, then deploy the app, then add DNS and HTTPS, then back it up.71015

A clean setup sequence is:

  1. Log in over SSH.
  2. Update the OS.
  3. Create a non-root user and enable sudo.
  4. Lock down the firewall with UFW.
  5. Install Docker and Docker Compose.
  6. Create a project directory for n8n.
  7. Add the Compose file and environment variables.
  8. Bring up the stack.
  9. Put the proxy and SSL in front of it.71015

That order matters because it reduces the chance of exposing n8n too early. Current guidance is to keep port 5678 off the public internet and expose only 80 and 443 through the proxy and firewall.347 In other words, n8n should listen locally or on a private network, while the reverse proxy handles the public-facing traffic.34

How do DNS, HTTPS, and the reverse proxy fit together?

DNS and TLS are required, not optional, in a real n8n vps setup.2310 The standard pattern is to create an A record such as n8n.example.com pointing to the VPS public IP, then issue a free Let’s Encrypt certificate through the reverse proxy.2310

The proxy layer is what makes the stack feel production-ready. It terminates HTTPS, forwards traffic to n8n on the private side, and keeps the application port from being directly reachable.134 Guides using Nginx, Caddy, or Traefik all converge on the same outcome: a clean public URL with encrypted traffic and no exposed internal service port.123

The operational implication is straightforward:

  • Open 80/443 for the proxy.
  • Keep 5678 private.
  • Point the subdomain at the VPS IP.
  • Let the proxy handle certificates.234

That arrangement is especially useful if you expect webhooks, because n8n’s callback URLs must match the public address users and services can reach. If the proxy or hostname is wrong, webhooks break even when the container is otherwise healthy.47

Which environment variables matter most in n8n?

The most important variables are WEBHOOK_URL, N8N_HOST, N8N_PROTOCOL=https, and N8N_ENCRYPTION_KEY.4710 Current guides call these out because they affect webhook routing, public URL generation, and credential protection in self-hosted deployments.4710

A simple way to think about them:

  • N8N_HOST tells n8n the hostname it should consider canonical.
  • N8N_PROTOCOL=https ensures generated URLs match your TLS setup.
  • WEBHOOK_URL helps external services hit the correct callback address.
  • N8N_ENCRYPTION_KEY protects stored credentials and should be persistent.4710

If you change domains later without updating these values, you can end up with mismatched webhook endpoints or stale links in nodes and credentials.410 That is why most current tutorials treat the .env file as part of the deployment, not an optional convenience.710

What does the practical build look like end to end?

The practical build is a small set of moving parts: Docker, Docker Compose, PostgreSQL, a reverse proxy, TLS, and backups.12710 This is the version that aligns with the “one VPS, one database, one reverse proxy” approach used in current 2026 self-hosting guides.39

A realistic implementation flow is:

  • Provision Ubuntu 22.04 or 24.04 on a low-cost VPS.
  • SSH in and harden access.
  • Install Docker and Docker Compose.
  • Create a private network for n8n and PostgreSQL.
  • Define the Compose file with persistent volumes.
  • Add the environment variables.
  • Configure DNS for your subdomain.
  • Put Nginx, Caddy, or Traefik in front.
  • Issue a Let’s Encrypt certificate.
  • Verify webhook access and log output.
  • Set up backups and update discipline.1271015

The reason PostgreSQL keeps appearing in 2026 guides is stability. Multiple tutorials recommend PostgreSQL over SQLite for self-hosted production-style use because it is the standard persistence layer in these deployments.2710 SQLite may boot a simple install, but the current production baseline is PostgreSQL on a private Docker network.2710

What are the main trade-offs between quick and durable setups?

The trade-off is speed versus resilience: a quick demo can be up fast, but a durable n8n vps setup is worth the extra few steps.589 The current guides are not really advocating complexity; they are advocating avoiding avoidable failure points, especially around storage, network exposure, and webhook routing.134

ApproachSpeedCostReliabilityBest for
Bare n8n on public portFastestLowestWeakThrowaway testing
n8n + SQLiteFastLowModerateVery light use
n8n + PostgreSQL + proxySlightly slowerLowStrongReal workloads
n8n + queue mode + larger VPSSlowerHigherStrongestHeavy automation

The “tiny VPS always works” assumption is where many setups become brittle. Recent 2026 guidance repeatedly recommends 2–4 GB RAM for reliability, especially if you use queue mode or heavier nodes.56 For a lean automation stack, that is still inexpensive compared with paying for a premium hosted automation plan that you may not fully use.39

What should you do after the first deployment?

You should test webhooks, confirm HTTPS, verify backups, and plan updates before you call the setup finished.71015 The best self-hosted stack is not the one that starts once; it is the one that survives the first update and the first restore test.1015

After the initial launch, check these items:

  • Visit the subdomain over HTTPS.
  • Confirm n8n generates the correct public URLs.
  • Trigger a test webhook from an external service.
  • Inspect Docker logs for database or proxy errors.
  • Back up the PostgreSQL data volume.
  • Document how to update the containers safely.71015

That final step matters because self-hosting is an operations habit, not a one-time install. The 2026 tutorials that are getting the most traction all cover the same extra pieces beyond “docker compose up -d”: firewall, proxy, SSL, persistence, and backup strategy.71015 If you want lean rather than fragile, those are the parts to keep.

Frequently asked questions

How much RAM do I need for n8n on a VPS?+

For a small production-style setup, start with 2 vCPU and 4 GB RAM. Several 2026 guides say 2 GB can work for lighter workloads, but 4 GB is the safer default if you use queue mode, browser automation, or AI-heavy nodes.

Should I expose port 5678 directly to the internet?+

No. Current guidance is to keep n8n behind a reverse proxy and expose only 80 and 443 publicly. Port 5678 should stay private, usually bound locally or kept inside a Docker network.

Can I use SQLite instead of PostgreSQL?+

Yes. The current production baseline is n8n plus PostgreSQL on a private Docker network. PostgreSQL is preferred for persistence and stability; SQLite is more of a lightweight or non-production option.

Do I need a domain name and SSL for n8n?+

Yes. Point a subdomain such as n8n.example.com to the VPS IP with an A record, then let your reverse proxy request a free Let’s Encrypt certificate. That gives you HTTPS without a paid certificate.

What’s the minimum stack I should plan for?+

The essential pieces are SSH hardening, Docker, Docker Compose, PostgreSQL, a reverse proxy, DNS, SSL, backups, and a sensible update process. Current tutorials treat those as the real baseline, not optional extras.

Sources

  1. How to Self-Host n8n on a VPS (2026 Guide)veerhost.com
  2. Self Host n8n on a VPS in 2026: Full Docker Setup Guide - Hostaccenthostaccent.com
  3. Self-host n8n on a VPS: Docker + HTTPSssdnodes.com
  4. How to Self-Host n8n (2026 Setup Guide) - mith.techmith.tech
  5. Self-Host n8n on a VPS: Docker Guide explained - AI Tool Curatoraitoolcurator.com
  6. VPS Giá Rẻ Chạy n8n Cấu Hình Như Thế Nào? Hướng Dẫn Chi Tiết ...nhatmkt.com
  7. Self-Hosting n8n with Docker: The Complete Setup Guide (2026)shrivatsatrivedi.com
  8. Self-host n8n on a VPS: Docker + HTTPSssdnodes.com
  9. 🔗 Self-Host n8n on VPS with Docker, SSL and PostgreSQLcloud.servermall.com
  10. Tự host n8n trên VPS: deploy Docker Compose với Postgres, HTTPS và backup | thueVPSthuevps.com
  11. Self-Host n8n with Docker: Complete Guide + Static IP for 403 ...outboundgateway.com
  12. Chapter 6: Self-Host n8n on a Linux VPS with Nginx and SSLpro.tecmint.com
  13. Self-Host n8n on a VPS: Docker Guide explained - AI Tool Curatoraitoolcurator.com
  14. 🔗 Self-Host n8n on VPS with Docker, SSL and PostgreSQLcloud.servermall.com
  15. Self-Host n8n with Docker: Complete Guide + Static IP for 403 ...outboundgateway.com
#n8n#vps#docker#self-hosting#automation#postgresql

Keep reading