Self-hosting n8n on a VPS such as Hetzner or DigitalOcean

A single virtual server can run a small production n8n with Docker Compose, Caddy for HTTPS, PostgreSQL and tested backups. This page covers the design, the setup sequence and the point where queue mode becomes necessary.

On this page

Self-hosting n8n on a VPS: when one server is enough

A single virtual server running Docker Compose, Caddy, PostgreSQL and scheduled backups is a reasonable production footing for a small n8n workload, provided the team accepts that one machine is one point of failure. The stack is small: n8n runs as one container, PostgreSQL holds workflows, credentials and execution history in place of the default SQLite file, and Caddy terminates HTTPS and renews certificates automatically. Everything sits on hardware and in an account the organization controls, so no workflow data has to pass through a vendor cloud.

Licensing comes first in the planning. n8n is source-available under the Sustainable Use License, not open source under an OSI-approved license. The license allows use and modification for your own internal business purposes, and the Community edition is free for that use. A business that runs n8n to automate its own processes falls within that allowance, but a business that embeds n8n in a product it sells, or hosts it for other companies, needs to read the license terms with counsel before going live. Files with .ee in their name or directory fall outside the Sustainable Use License and require a valid n8n Enterprise License, so confirm that the edition you deploy does not depend on them.

Before you commit to one server, confirm three things: the expected number of concurrent executions, how long an outage can last before workflows stop mattering, and whether SSO or multi-main high availability is required. The Business and Enterprise plans include SSO, and multi-main setup is restricted to Enterprise self-hosted deployments, so a team that needs either will not get it from the Community edition. The sibling topic on queue mode covers the point where one VPS stops being enough.

Which VPS design fits which team

This table compares four ways to run n8n on a single VPS or a small set of servers, from a single-container SQLite setup to queue mode with separate workers. Read each row against your team size, your uptime expectations and how much operator time you can spend on patching, backups and database care. The main takeaway is that SQLite is not the production choice in the Compose guidance, and that multi-main high availability is limited to Enterprise self-hosted deployments.

DesignWhen it fitsOperator time and limits
Single Compose stack with SQLitePersonal tests, proofs of concept or a short-lived internal trial with no business-critical workflowsLowest setup effort, but not the production choice in the Compose guidance. Backups are file-based and the design cannot grow into multiple processes.
Compose stack with PostgreSQL and CaddyA small production team with a modest number of workflows and one owner for patching and backupsModerate setup effort. You own the Compose file, Caddy certificates, PostgreSQL backups, host patching and the encryption key. Single host, so a host failure stops all automations.
Managed PostgreSQL beside the VPSTeams that want database backups, minor patching and failover handled by a provider while the VPS stays smallAdds a second bill and a network path to secure. You still own n8n upgrades, the encryption key and firewall rules. Confirm TLS to the database and provider backup retention before choosing it.
Queue mode with separate workers on several serversHigher execution volume, workflows that must not wait behind webhooks, or teams that need to scale workers independentlyHighest operator time: Redis, shared encryption key on every worker and webhook process, PostgreSQL sizing and worker monitoring. Multi-main high availability is Enterprise self-hosted only, so the main instance remains a single point of failure in the Community edition.

How to set up n8n on a VPS step by step

This sequence takes a blank virtual server to a private n8n instance behind automatic HTTPS, with encrypted credentials, persistent PostgreSQL data, and a backup you have proven you can restore.

  1. Provision the server and DNS record

    Create a virtual server with a current Linux distribution from your provider, and note its public IP address. Point a DNS A record for the hostname you will use for n8n (for example, an illustrative n8n.example.com) at that address, and wait for the record to resolve from more than one network. Confirm the server's region and data residency terms with the provider before loading any workflow data. Check: dig +short n8n.example.com returns the server's public IP.

  2. Harden SSH and enable the firewall

    Log in with a non-root administrative account that uses SSH keys, disable password login and direct root login in the SSH daemon configuration, then restart the SSH service. Enable a host firewall that allows only ports 22 (or your chosen SSH port), 80 and 443, and deny everything else. Keep an existing SSH session open while you test a second login, so a mistake cannot lock you out. Check: a new SSH session with your key succeeds, password login is refused, and a port scan shows only the three allowed ports open.

  3. Install Docker and the Compose plugin

    Install Docker Engine and the Compose plugin from Docker's official repository for your distribution, and add your administrative account to the docker group only if you accept that membership grants root-equivalent control. Confirm the installed versions and that the daemon starts on boot. Check: docker compose version prints a version, and docker run --rm hello-world completes successfully.

  4. Write the Compose file with n8n, PostgreSQL and Caddy

    Create a project directory with a docker-compose.yml that defines three services: n8n, PostgreSQL, and Caddy as the reverse proxy that obtains and renews the TLS certificate. Set n8n to use PostgreSQL rather than the default SQLite database, set the public hostname and webhook URL to your DNS name over HTTPS, and pin each image to a specific tag. Check the image tags against the n8n release notes before you pin them, and confirm the Caddy and PostgreSQL tags against their own release pages. Check: docker compose config renders without errors and shows no secrets in the output you will share.

  5. Set the encryption key and persistent volumes

    Generate a long random value for n8n's encryption key and store it in a .env file readable only by the administrative account. Back this key up in your secrets store right away, because n8n uses it to decrypt stored credentials, and a lost key means those credentials cannot be recovered. Mount named volumes or host paths for the n8n data directory, the PostgreSQL data directory, and Caddy's certificate storage so they survive container recreation. Check: the key is present in .env and in your secrets store, and docker volume ls lists each data volume.

  6. Start the stack and confirm HTTPS and the webhook URL

    Start the services with docker compose up -d, then read the logs for n8n, PostgreSQL and Caddy to confirm each service reached a ready state without database connection errors. Open the n8n hostname in a browser, complete the owner account setup, and confirm the certificate is issued by a public authority and matches the hostname. Create a test workflow with a Webhook trigger and a Respond to Webhook node, then call its production URL from outside your network to confirm the URL uses your public hostname and HTTPS. Check: the webhook returns the expected response, and the address bar shows a valid certificate.

  7. Configure backups for the database and data volumes

    Schedule a backup of the PostgreSQL database with a logical dump, and archive the n8n data directory and the encryption key record. Store copies off the server, in a location with separate access controls, and encrypt them before they leave the machine. Decide and document how long backups are retained and who can restore them, since those choices depend on your own policies and any regulatory duties that apply to your data. Check: the scheduled job completes once and produces a dump file of non-zero size in the off-server location.

  8. Test a restore on a separate server

    Restore the latest backup onto a second, separate server or a disposable container set, using the same Compose file and the saved encryption key. Open the restored instance, confirm your test workflow and a sample credential are present and that the credential still works, and run the webhook once. Record what the restore required, including any manual steps, and update the runbook with them. Check: the restored instance serves the test workflow, the credential decrypts, and the runbook reflects the steps you actually used. A backup you have not restored is not yet a recovery plan.

How Caddy handles HTTPS and webhook URLs on one host

On a single VPS, only Caddy should publish ports 80 and 443. A request from the internet reaches the host, Caddy terminates TLS for your hostname, and it forwards the request over the internal Docker network to the n8n container on its application port. The n8n container and the PostgreSQL container should have no published ports at all. Keeping them off the public interface means the only way in is through Caddy, which is where you control certificates and which requests get through. Confirm this with a port scan from outside the host after every change to the Compose file, because a ports: entry added for debugging is the most common way this rule gets broken.

The public hostname must match the webhook URL that n8n generates. n8n builds webhook and editor URLs from its own configuration, so the setting that holds the public address (for example N8N_HOST, N8N_PROTOCOL and the webhook URL variable, which you should confirm against the version you pin) must describe the address users and external services actually call, including the https scheme. If n8n believes it is served on an internal name or on plain HTTP, webhook URLs shown in the editor will be wrong, and services that register them with third parties will call addresses that do not resolve or do not answer. Treat the hostname as a single value you decide once, put it in the DNS record Caddy uses for its certificate, and use the same value everywhere in the stack.

Caddy obtains and renews the certificate automatically once the DNS record points at the VPS and ports 80 and 443 are reachable, so the operational work is verifying those prerequisites and watching renewal logs rather than managing certificate files by hand. Header handling, proxy hop counts and subfolder hosting have their own page, so this section does not repeat them. Check the forwarded-header and hop settings there before you assume webhooks are correct, because a wrong hop count produces webhook errors even when HTTPS works.

Securing the server, the database and the encryption key

On one VPS, the server, the database and the encryption key all sit on the same trust boundary, so a weakness in any one exposes the others. The cards below cover the controls that close the most likely paths in, and the secrets that must survive a rebuild. Work through them before the first workflow touches a production credential.

SSH key-only access and firewall rules

Create a non-root administrative user, install your public key, and disable password logins and direct root login in the SSH daemon configuration. Then allow only the ports the stack needs: SSH from known source addresses where possible, and HTTP and HTTPS for Caddy. Deny everything else by default at the provider firewall and on the host. Confirm the rules from outside the network with a port scan before you close your current session.

Keeping PostgreSQL off public ports

Run PostgreSQL on the Compose internal network only, with no ports mapping to the host. Anything published on the host can be reached from the internet unless the firewall blocks it, and Docker can bypass some host firewall rules when ports are published, so do not rely on the firewall alone. Use a strong, unique database password and confirm with a port check that 5432 does not answer from outside.

Backing up and protecting the encryption key

n8n encrypts stored credentials with the key in N8N_ENCRYPTION_KEY. A database backup without that key cannot recover the credentials, and a key without the database recovers nothing. Store the key in a password manager or secrets vault separate from the server, and record which key belongs to which instance. If you later add queue mode, the same key must be set on every worker and webhook processor, so plan that copy now.

Queue mode docs

Restricting the admin account and exposing only needed webhooks

Create the owner account with a strong password and a second administrator only where needed, then review user roles after each change. Keep the editor UI reachable only to staff, for example through an IP allowlist or a VPN, if your network allows it. Expose only the webhook paths that external systems call, and block the rest at the proxy so the full UI is not public to the internet.

Pinning the image and applying patches

Pin the n8n image to an exact version tag rather than latest, so an upgrade happens when you choose it. Track the release notes for security fixes and breaking changes, and plan a test restore before each upgrade. Apply operating system updates on a schedule, and confirm the host restarts cleanly after kernel updates. Record the pinned version in your change log so you know what was running during any incident.

n8n release notes

How the single-VPS stack fits together

The diagram starts at the public internet, where traffic reaches only Caddy on ports 80 and 443. Caddy terminates HTTPS and forwards requests to n8n over the private Docker network, which is the trust boundary to check first. n8n reads and writes its data in PostgreSQL, which has no public port. A backup job writes copies off the host, and SSH is the only administrative path into the server. Confirm that no other container publishes a port and that the backup destination sits outside the VPS.

Traffic enters through Caddy only, and administration happens over SSH.

When one VPS needs queue mode

A single n8n process handles triggers, webhooks and executions together, so load in one area can slow the others. Queue mode separates those roles, but it adds Redis, workers and shared secrets, so it should follow evidence from your own instance rather than a guess.

Executions queuing behind each other

Watch for long-running or frequent workflows that delay others until a slot frees up. If scheduled jobs start late or manual runs wait, the single process is saturated. Check the execution list for growing wait times at peak hours before you change anything. Queue mode lets you add worker capacity without touching the main instance, but only if the bottleneck is execution work and not the external APIs your workflows call.

Webhook latency under load

Slow webhook responses during bursts are the most visible sign. Callers such as payment, form or chat providers may time out and retry, which creates duplicate work. Measure response times for your busiest webhook while a large execution batch is running. If responses slow only when executions run, trigger handling and execution compete for the same process, and separating them is a sound next step.

A need to separate trigger handling

Queue mode assigns the main instance to triggers and webhooks, and passes executions to workers. This split matters when one role must stay responsive while another does heavy work, such as large data transforms or AI calls. Decide which workflows are latency-sensitive and which are batch work. Document that split before you deploy, because it determines how many workers and how much Redis capacity you need.

Queue mode docs

Redis and PostgreSQL as shared dependencies

In queue mode, executions pass through Redis, and workers read and write workflow data in PostgreSQL. Redis becomes a new component to secure, back up and monitor, and PostgreSQL must absorb more connections from every worker. Confirm that your database host has connection headroom, and plan where Redis runs on the same VPS or on a separate host. Both add cost and operational work to the single-server design.

Shared encryption key across every node

Every worker and webhook processor must use the same encryption key as the main instance so it can decrypt stored credentials. Treat that key as a secret distributed to each process, store it in your secrets process, and rotate it only with a planned procedure. A mismatched key causes credential failures that look like broken integrations, so verify it on each node after any change.

High availability is an Enterprise feature

Running several main instances for high availability, called multi-main setup, is limited to Enterprise self-hosted deployments and is not available in the Community edition. A VPS running Community edition therefore gets queue mode for throughput, not failover of the main instance. Confirm your edition and plan before designing for uptime, and ask n8n which license covers your required topology.

Queue mode docs

Measure before you decide

Record execution wait time, webhook response time, CPU, memory and database connections over a normal week, including peak hours. Set a threshold that would justify queue mode, such as sustained waits that miss business deadlines. Repeat the measurement after a change to confirm it helped. Queue mode adds moving parts, so a measured bottleneck should drive the decision, not the expectation that more architecture is safer.

Questions buyers ask about hosting n8n on a VPS

What does it cost to host n8n on a VPS and what drives the cost?

The cost has three parts: the server, the people who build and run it, and the recurring work after launch. The virtual server is usually the smallest line item, and the provider's published price for it is the figure to check. Staff time is the larger cost, covering the initial build, testing of backups and restores, firewall and proxy configuration, and upgrades. Scope moves the total up or down: one instance with a single domain is simpler than several environments with SSO and an external database. DeployOpen does not publish prices. A quote follows from a written scope, so ask for the server specification, the hours by task, the retainer terms for upgrades and monitoring, and which items are one-time and which recur. Licensing is separate: n8n's Community edition is free to self-host under the Sustainable Use License, while SSO and some other features require a paid plan listed on n8n's pricing page.

How long does a first n8n VPS build take?

The duration depends on scope and on how ready your environment is, so no fixed figure applies. A single instance with a domain you already control, a working DNS zone, an agreed backup target and a clear owner can move through the build quickly. Delays usually come from waiting on access, DNS changes, decisions about backup retention, or testing of restores. Scope adds time when you need SSO, several environments, custom certificates or a move from an existing n8n installation. Ask for a written plan that lists the stages (provisioning, Compose and proxy configuration, database, firewall, backups, restore test, handover) and the client dependencies at each stage. Timelines in a fixed-scope agreement are set in writing before work starts, so the plan should show what would extend them.

What does our internal team need to provide for an n8n VPS deployment?

Your team provides the inputs that only your organization can supply. The main items are:

  • A domain or subdomain for n8n, with permission to create DNS records that point to the server
  • Accounts with the hosting provider and the cloud or network access needed to create the server and manage its firewall
  • A backup target, such as object storage or a separate host, with credentials and a retention policy
  • Named owners for the platform, for access approvals, and for incident response
  • A decision on who may sign in, how administrators are named, and whether SSO is in scope
  • The data classification for the workflows and credentials n8n will hold

Without these, the build stalls at the points where configuration needs a decision. Confirm each item with your own change process before the build begins.

Can our team build and run n8n on a VPS without a partner?

Yes, a capable platform or DevOps team can build a single-server n8n setup, provided it has experience with Linux administration, Docker, reverse proxies and PostgreSQL. The common failure points are predictable. Teams expose the database or n8n directly to the internet, skip the encryption key backup so credentials cannot be decrypted after a rebuild, leave webhook URLs and forwarded headers misconfigured behind the proxy, and never test a restore. Upgrades are another gap: n8n ships minor releases frequently, and major versions bring breaking changes that need a planned window. Before deciding, ask whether someone on your team can own these tasks every week, not just at launch. If the answer is uncertain, a fixed-scope build with handover documentation and a retainer for upgrades is a common middle path.

Is a VPS acceptable for regulated or sensitive data in n8n?

A VPS can be part of a compliant design, but the decision depends on your regulator, your data classification and the provider's controls, not on the server type alone. Your compliance team should confirm the provider's location, shared-responsibility terms, encryption options and access logging against your own requirements. On the application side, the controls that matter most are the encryption key stored outside the server, PostgreSQL that is not reachable from the internet, TLS on every public endpoint, restricted administrator access, logging of changes and an access review. DeployOpen prepares systems, controls and evidence for compliance assessments, but independent auditors and certification bodies issue any audit report or certification. Ask your assessor early which evidence they will request.

When should n8n move from a single VPS to queue mode or Kubernetes?

Move to queue mode when one instance can no longer process the execution volume or isolate heavy workloads, not because the server feels slow. In queue mode, the main instance handles triggers and webhooks and passes executions through Redis to worker processes that read and write PostgreSQL. Watch for sustained queueing, long-running executions that delay others, webhook latency during peaks, and memory pressure that restarts the process. The encryption key must be shared with every worker and webhook processor, so the key handling in your secrets process must be ready first. Kubernetes becomes worth considering when you need automated scaling, several environments managed as code, or cluster-level policies your organization already runs. Multi-main high availability is limited to Enterprise self-hosted deployments, so a single VPS cannot provide that setting in the Community edition.

What should we check before the first n8n VPS upgrade?

Check the release notes for the target version, the breaking changes that apply to your installed nodes and features, and whether your database and proxy settings still match the new release. Back up the database and the encryption key first, then run the upgrade in a staging copy built from the same Compose file and image tag. Test your critical workflows, webhooks and credentials against the staging copy, and keep the previous image tag available for rollback. n8n uses semantic versioning and publishes minor releases frequently, so a steady schedule is easier to manage than large jumps. Put the upgrade window, the test list and the rollback owner into your change record before the work starts.

How do we verify that n8n backups actually restore?

A backup counts only after a restore has been tested on a separate server. Confirm three things: the PostgreSQL dump or snapshot restores cleanly, the n8n encryption key is stored separately and restores with it, and the restored instance can run a sample workflow and decrypt an existing credential. Schedule the restore test at a set interval and record the result, the time taken and any gaps. Store backups off the VPS so a server failure or account compromise does not remove both copies. Ask your partner or internal team to name who performs the test and where the evidence is kept.

How DeployOpen scopes and delivers an n8n VPS deployment

DeployOpen is a Chainscore Labs company that plans, implements, hardens, backs up, upgrades, documents and supports self-hosted open-source platforms inside infrastructure you control. For an n8n VPS deployment, that means the virtual server, the Docker Compose stack with Caddy, the PostgreSQL database, firewall rules, backup jobs and the handover documents all run in an account you own, such as your Hetzner or DigitalOcean project. Most engagements are fixed-scope, so the server count, domain names, number of n8n instances, backup destination and whether a queue mode step is included are agreed in writing before any work starts. Ask for that written scope to state which of these items are in and which are explicitly out.

The most useful part of the written scope is the acceptance criteria. Ask that the plan name the test that closes the build. DeployOpen treats a restore test as a delivery gate: a recent backup of the PostgreSQL database and the n8n data volume is restored to a separate VPS or local environment, and the instance is started against it with the same N8N_ENCRYPTION_KEY. Credentials that cannot be decrypted after restore are a failed backup, not a minor finding, so the gate checks that the key was stored outside the server and that workflows and credentials return intact. Confirm with your team which recovery time and data loss targets the restore test should prove, because those are business decisions, not vendor defaults.

Handover documentation covers what your operators need after the engagement ends: the Compose file and its pinned image tags, the list of environment variables and where each secret lives, the firewall and SSH policy, the backup schedule and restore runbook, the upgrade procedure, and the point at which a single VPS should move to queue mode. Retainers are optional and cover planned upgrades, patch windows and continuous testing of the instance. Ask for the retainer scope in writing as a separate line item from the build, so you can decide whether to keep the work in house after handover.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.