Skip to content
Client area

n8n on a VPS: When to Self-Host and How to Get Started

n8n on a VPS: When to Self-Host and How to Get Started

A customer fills out a form on your website. Someone has to put the inquiry in the CRM and alert the right person. If the CRM is down, the inquiry still needs a way to reach the team. Doing this by hand works for a few inquiries, but it gets old when the same steps repeat every day.

That’s where n8n comes in. You tell it what starts the workflow, which data to pass along, and what to do if a step fails. You could ask an AI model to suggest a category and let a person handle the routing. Save the inquiry first so a slow or confused model doesn’t hold it up.

You can try n8n on your computer. Your website, however, can receive a form submission long after you close the laptop. For overnight webhooks and scheduled workflows, you need somewhere for n8n to keep running. That’s when it makes sense to compare your own VPS, n8n Cloud, and other managed providers.

Skip to setup

What you gain by running your own VPS

A VPS is worth considering if n8n needs access to an internal database, CRM, or API. You can connect the instance to your network over a VPN and allow access only to the addresses it needs. The internal service can stay private. You still have to configure the route and permissions.

You also get to choose when to update and how long to keep execution history. If downtime would interrupt incoming inquiries, try a change on a separate copy first. That helps when someone owns the update process, checks backups, and knows how to restore the service.

Option When it fits What to check before paying
n8n Cloud You want a quick start, your apps have accessible APIs, and you don’t need OS access Execution and concurrency limits, plan features, region, and data retention
Another managed n8n provider You want help running the service or connecting it to your network Who updates it, handles recovery, gives you access to backups, and helps when it breaks
Your own Linux VPS You need control over networking, versions, and data retention and have someone to run it Resources under load, recovery time, maintenance responsibilities, and edition features

A ready-made install saves work on day one. Ask what happens a month later if an update breaks a workflow, and what you can take with you if you move. A workflow export serves a different purpose from a database backup and its encryption key. Check what data you can retrieve and how you would reconnect your accounts.

What goes into the cost

For a managed service, count the subscription, plan limits, and work outside the agreement. On a VPS, budget for the server, backups, administration, and any paid n8n edition you need. Compare the same time period and workload. A workflow that polls a source once every five minutes, around the clock, runs about 8,640 times in 30 days. Check how the plan counts runs and whether a webhook can replace polling.

Community Edition covers many internal workflows. For features such as SSO or separate environments, check the n8n plan comparison. If customers will configure workflows themselves or pay for access to n8n, check the license terms first.

An external AI API may cost extra whichever hosting option you choose. n8n prepares the request and handles the result on the VPS while the provider runs the model. This example needs no GPU. The payload still leaves your server. If all you need is an inquiry category, start with anonymized text. Names, phone numbers, credentials, and documents seldom help with that test.

How to size the server

Start with peak event volume, workflow duration, and the size of the data held in memory. Ten large file jobs in parallel can need far more memory than ten short API calls. The shorter jobs might hit an external rate limit first.

The setup below uses a single instance with SQLite on a persistent volume for a small internal workflow. Watch memory, CPU, disk, execution history, and runtime under a representative workload. Run docker stats --no-stream during a series of tests and track how much the volume grows. If long runs hold up new requests, measure where the time goes before planning a separate PostgreSQL and worker setup.

Set up n8n on a VPS with Docker Compose

Use a dedicated Linux VPS with Docker Engine and the Compose plugin, a subdomain pointed at it, and inbound TCP ports 80 and 443 available for Caddy. If a reverse proxy already owns those ports, configure it to route to n8n. Allow outbound HTTPS. In this example, n8n’s port 5678 stays on the Compose network while Caddy handles public HTTPS.

Check that Docker and Compose are available. Follow the Docker installation guide for your Linux distribution if needed.

docker --version docker compose version mkdir -p ~/n8n-stack cd ~/n8n-stack umask 077

Create compose.yaml and Caddyfile from the examples below. In .env, set your hostname and exact supported stable image tags. Create a unique encryption key with openssl rand -hex 32, replace the placeholder, and keep a copy in secure storage. n8n needs that key to decrypt restored credentials.

N8N_DOMAIN=n8n.example.com N8N_VERSION=VERSION CADDY_VERSION=VERSION N8N_ENCRYPTION_KEY=REPLACE_WITH_GENERATED_KEY

compose.yaml

services: n8n: image: docker.n8n.io/n8nio/n8n:${N8N_VERSION:?Set N8N_VERSION in .env} restart: unless-stopped environment: N8N_HOST: "${N8N_DOMAIN:?Set N8N_DOMAIN in .env}" N8N_PROTOCOL: https N8N_EDITOR_BASE_URL: "https://${N8N_DOMAIN}/" N8N_WEBHOOK_URL: "https://${N8N_DOMAIN}/" N8N_PROXY_HOPS: "1" N8N_ENCRYPTION_KEY: "${N8N_ENCRYPTION_KEY:?Set an encryption key in .env}" EXECUTIONS_DATA_PRUNE: "true" EXECUTIONS_DATA_MAX_AGE: "168" volumes: - n8n_data:/home/node/.n8n caddy: image: caddy:${CADDY_VERSION:?Set CADDY_VERSION in .env} restart: unless-stopped environment: N8N_DOMAIN: "${N8N_DOMAIN}" ports: - "80:80" - "443:443" volumes: - ./Caddyfile:/etc/caddy/Caddyfile:ro - caddy_data:/data - caddy_config:/config volumes: n8n_data: caddy_data: caddy_config:

Caddyfile

{$N8N_DOMAIN} { reverse_proxy n8n:5678 }
chmod 600 .env docker compose config --quiet docker compose up -d docker compose ps curl -fsS https://n8n.example.com/healthz/readiness

Replace the example hostname in the last command. Give the service time to start and check again if needed. Open your subdomain over HTTPS, create the owner account, and enable two-factor authentication. Set up the instance before connecting external senders and limit editor access to people who need it.

N8N_WEBHOOK_URL sets the public URL that senders should use. N8N_PROXY_HOPS=1 matches the single reverse proxy in this example. If you also use a CDN or a load balancer, check the number of hops and proxy trust settings for your setup. n8n webhook and reverse proxy guide.

Try your first AI workflow

Start with Manual Trigger → HTTP Request. Ask the model to categorize a fictional inquiry about missing website form email. This tests the API connection before you enable a webhook or send customer data.

In HTTP Request, send a POST to https://openrouter.ai/api/v1/chat/completions. Store the key in Credentials as an Authorization header with the value Bearer <key>. Keep it out of the workflow body and screenshots. Select JSON and replace the model placeholder with a text model ID available to you. OpenRouter quickstart.

{ "model": "REPLACE_WITH_MODEL_ID", "messages": [ { "role": "system", "content": "Return one category from: email, billing, other. Return only the category." }, { "role": "user", "content": "I am not receiving email from the website form." } ], "max_tokens": 32 }

Look for HTTP 200 and a category in choices[0].message.content. In production, check it against your allowed categories and send unexpected responses or API failures to manual review. Save the inquiry before calling the model so a failure there doesn’t hold up intake.

Test incoming events in a separate workflow with a Webhook node, POST, and Header Auth. Create a separate secret for that endpoint and send a request to its Test URL while the node is listening. Publish the workflow and try its Production URL. Look for a successful response and a new entry under Executions. Confirm that a bad secret is rejected before connecting the endpoint to a paid model.

Checks before going live

  • If Caddy can’t issue a certificate, check the DNS records, including any outdated AAAA record, test access to 80/443, and run docker compose logs caddy.
  • If the editor loads but the webhook returns 404, check that the workflow is published and you have the Production URL. For a 401, check the authentication header name and value.
  • If the model doesn’t respond, check your key, model access, and quotas. On 429, honor the provider’s wait times and limit retries, especially if a retry could create a duplicate inquiry.
  • Run docker compose restart n8n. Sign in again, confirm the workflow and credentials are still there, and call the published webhook again.

Keep a copy of the volume, configuration, and encryption key outside the VPS. For this SQLite setup, schedule a brief stop so you can take a consistent copy of the volume before starting it again. Test the restore on another instance. Back up before changing the image tag, since switching back to an old tag may not undo a database migration. The example keeps seven days of execution history. Adjust that for debugging and for the data your workflows store.

What to automate first on your VPS

Start with the inquiry from the beginning of the article. Receive it and save it to the CRM. Try several test inquiries and see how you would learn that the CRM isn’t responding. Once the basic path works, add a notification for the team. Add AI categorization separately so the model’s response time doesn’t hold up the main workflow.

A few days of normal use give you numbers no plan table can provide: how many requests arrive together, how long runs take, and how fast history grows. Use those numbers to decide whether the server has enough capacity and what to move next. Try restoring a backup while only one workflow depends on the instance.

If you want control over networking, updates, and storage, size a Host4Biz Linux VPS for that first workflow. Pick something your team does every day. A good first result is simple: the inquiry is already in the CRM when someone sits down to respond.

Black Friday at Host4Biz

See the deals