Self-Hosting n8n on a $5/mo Cloud VPS Using Docker Compose
Deploying your own workflow automation server doesn't have to break the bank. Learning how to self host n8n docker vps deployments using Docker Compose gives you complete data privacy, unrestricted workflow executions, and full control over your server environment for as little as $5 per month. In this step-by-step technical guide, we will cover provisioning a budget cloud server, installing Docker, configuring Docker Compose with automatic SSL via Caddy, and securing your production n8n instance.
⚡ Why Choose a $5/mo VPS + Docker Compose for n8n?
Running n8n on a budget Virtual Private Server (such as Hetzner, DigitalOcean, or Vultr with 1 GB RAM / 1 vCPU) is more than sufficient for running dozens of active workflows. Using Docker Compose containerizes n8n alongside a reverse proxy like Caddy or Nginx, making updates, backups, and SSL management completely painless.
Prerequisites for Setting Up Your n8n Docker VPS
Before executing the terminal commands below, make sure you have the following components ready:
- Cloud VPS Account: A $5/mo instance (Ubuntu 22.04 or 24.04 LTS recommended) from Hetzner, DigitalOcean, Vultr, or Linode.
- Custom Domain / Subdomain: A domain name (e.g.,
n8n.yourdomain.com) with an A Record pointing directly to your VPS IPv4 address. - SSH Access: Terminal access to your VPS via SSH or PuTTY.
- Basic Command Line Knowledge: Basic familiarity with Linux terminal navigation and environment variables.
Step-by-Step Blueprint: Self-Hosting n8n with Docker Compose
Step 1: System Update and Docker Installation
SSH into your fresh Linux server as root or a user with sudo privileges, update your repository packages, and install Docker alongside the Docker Compose plugin:
# Update system packages
sudo apt update && sudo apt upgrade -y
# Install Docker prerequisites
sudo apt install -y curl ca-certificates gnupg lsb-release
# Install Docker & Docker Compose
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
# Verify Docker installation
docker --version
docker compose version
Step 2: Create Directory Structure and Environment File
Create a dedicated folder for your n8n docker vps stack and create an .env file to hold your domain and security configurations:
mkdir -p ~/n8n-docker && cd ~/n8n-docker
# Create the environment file
nano .env
Paste the following environment variables inside your .env file (replace placeholder values with your actual domain and credentials):
# Domain & Network Configuration
DOMAIN_NAME=n8n.yourdomain.com
SUBDOMAIN=n8n
USER_EMAIL=admin@yourdomain.com
# n8n General Settings
N8N_HOST=${DOMAIN_NAME}
N8N_PORT=5678
N8N_PROTOCOL=https
NODE_ENV=production
WEBHOOK_URL=https://${DOMAIN_NAME}/
GENERIC_TIMEZONE=America/New_York
Step 3: Define the Docker Compose File
Create a docker-compose.yml file in the same directory. We will use Caddy as an automated reverse proxy because it handles Let's Encrypt SSL certificates automatically without manual certbot scripting:
# Create docker-compose.yml
nano docker-compose.yml
Paste the complete stack definition below:
version: '3.8'
services:
caddy:
image: caddy:latest
restart: always
ports:
- "80:80"
- "443:443"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- caddy_data:/data
- caddy_config:/config
n8n:
image: docker.n8n.io/n8nio/n8n:latest
restart: always
ports:
- "5678:5678"
environment:
- N8N_HOST=${DOMAIN_NAME}
- N8N_PORT=5678
- N8N_PROTOCOL=https
- NODE_ENV=production
- WEBHOOK_URL=https://${DOMAIN_NAME}/
- GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
volumes:
- n8n_data:/home/node/.n8n
volumes:
caddy_data:
caddy_config:
n8n_data:
Step 4: Configure the Caddy Reverse Proxy
Create a Caddyfile to route incoming HTTPS traffic to your n8n container:
nano Caddyfile
Add the reverse proxy rule:
n8n.yourdomain.com {
reverse_proxy n8n:5678
}
Step 5: Launch the Stack & Access n8n
Start your containers in detached mode using Docker Compose:
docker compose up -d
Wait 30–60 seconds for Caddy to issue your SSL certificate, then navigate to https://n8n.yourdomain.com in your browser to complete your initial owner account creation!
Self-Hosted Architecture Summary
| Component | Technology | Role in Stack |
|---|---|---|
| Cloud Server | Ubuntu 22.04 LTS VPS | Provides computing power (1 vCPU / 1GB RAM minimum). |
| Container Runtime | Docker & Docker Compose | Isolated management of n8n application and database volumes. |
| Reverse Proxy | Caddy Web Server | Automatic SSL certification and HTTPS routing. |
| Workflow Engine | n8n Community Edition | Executes integrations, triggers, and AI automations. |
Troubleshooting & Common Docker VPS Errors
- Webhook 404 / Invalid URL: Ensure that
WEBHOOK_URLin your.envfile includeshttps://and ends with a trailing slash (e.g.,https://n8n.yourdomain.com/). - Out of Memory (OOM) Crashes: A $5/mo VPS with 1 GB RAM can occasionally run low on memory during heavy executions. Enable a 1 GB or 2 GB Linux Swap file using:
sudo fallocate -l 2G /swapfile && sudo chmod 600 /swapfile && sudo mkswap /swapfile && sudo swapon /swapfile - SSL Certificate Issuance Failure: Verify that port 80 and 443 are open in your VPS firewall (UFW) using
sudo ufw allow 80/tcp && sudo ufw allow 443/tcp.
Related Guides & Resources
Continue building your automated infrastructure with these PromptLogic tutorials:

Post a Comment for "Self-Hosting n8n on a $5/mo Cloud VPS Using Docker Compose"