DEV Community

Cover image for How to Set Up a VPS for Automation (Hetzner vs Contabo vs Railway)
Raizan
Raizan

Posted on • Originally published at chasebot.online

How to Set Up a VPS for Automation (Hetzner vs Contabo vs Railway)

What You'll Need


Table of Contents


The Real Cost of Cloud-First Automation

I spent two years running automation workflows on managed platforms before I switched to self-hosted. Here's what changed: my hosting costs dropped from $180/month to $8/month, and my workflow execution latency improved by 40%.

The catch? I had to learn infrastructure. But honestly, it's worth it.

When you're choosing between n8n Cloud and self-hosting, the decision isn't just about price. It's about control, scale, and whether you want to own the entire stack. If you're automating business processes—pulling data from APIs, building integrations, or running bots 24/7—a VPS gives you freedom that managed platforms don't.

The big question: which VPS provider should you actually use?

I've tested all three in production. Here's what I learned.


Hetzner vs Contabo vs Railway: Head-to-Head

Feature Hetzner Contabo Railway
Entry Price $3.29/mo (CX11) $3.99/mo (VPS 1) $5/month (pay-as-you-go)
Storage 25 GB NVMe 200 GB SSD Depends on usage
Bandwidth 20 TB/month Unlimited Metered
Setup Time ~5 minutes ~5 minutes ~2 minutes
Best For Production workloads, scaling Stable long-term hosting Serverless/quick deploys
UI Complexity Moderate Simple Very simple
Uptime SLA 99.9% 99.9% 99.95%

My take: If you're serious about automation—especially if you're considering 5 n8n workflows that replace $200/month in SaaS tools—you want Hetzner or Contabo. Railway is great for experimentation, but it's not cost-optimized for 24/7 workloads.

Here's why I pick Hetzner for most clients:

  1. Consistent performance. Their NVMe storage is fast even on the cheapest tier.
  2. Transparent pricing. No surprise overage charges.
  3. European data centers. Lower latency if you're in EU/Asia.
  4. Easy scaling. If your bot explodes, you resize in the control panel.

Contabo wins if you need more storage and don't want to pay per-GB. Railway wins if you want zero infrastructure knowledge required.


Setting Up Hetzner for n8n

I'm going to walk you through creating a production-ready Hetzner VPS instance running n8n.

Step 1: Create Your Hetzner Account and Deploy a Server

Sign up at Hetzner VPS. Go to CloudServersCreate Server.

  • Image: Ubuntu 22.04
  • Server Type: CX11 (2 vCPU, 2 GB RAM, 25 GB NVMe)
  • Location: Pick the closest to your users
  • Add SSH Key: Generate one locally first
ssh-keygen -t ed25519 -C "your-email@example.com" -f ~/.ssh/hetzner_key
Enter fullscreen mode Exit fullscreen mode

Copy the public key (~/.ssh/hetzner_key.pub) into Hetzner's SSH key field. Click Create.

Step 2: SSH Into Your Server

ssh -i ~/.ssh/hetzner_key root@your_server_ip
Enter fullscreen mode Exit fullscreen mode

Replace your_server_ip with the IP shown in Hetzner's console.

Step 3: Update the System

apt update
apt upgrade -y
apt install -y curl wget git nano vim
Enter fullscreen mode Exit fullscreen mode

Step 4: Install Docker and Docker Compose

curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
usermod -aG docker root
curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version
Enter fullscreen mode Exit fullscreen mode

Step 5: Set Up n8n with Docker Compose

Create a directory and a compose file:

mkdir -p /home/n8n && cd /home/n8n
nano docker-compose.yml
Enter fullscreen mode Exit fullscreen mode

Paste this (adjust N8N_HOST to your domain):

version: '3.8'

services:
  n8n:
    image: n8nio/n8n:latest
    container_name: n8n
    ports:
      - "5678:5678"
    environment:
      - N8N_HOST=automation.yourdomain.com
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - WEBHOOK_URL=https://automation.yourdomain.com/
      - EXECUTIONS_TIMEOUT=3600
      - EXECUTIONS_TIMEOUT_MAX=7200
    volumes:
      - n8n_data:/home/node/.n8n
    restart: always

  postgres:
    image: postgres:15-alpine
    container_name: n8n_db
    environment:
      - POSTGRES_USER=n8n_user
      - POSTGRES_PASSWORD=your_secure_password_here
      - POSTGRES_DB=n8n
    volumes:
      - postgres_data:/var/lib/postgresql/data
    restart: always

volumes:
  n8n_data:
  postgres_data:
Enter fullscreen mode Exit fullscreen mode

Replace your_secure_password_here with a strong password. Start the services:

docker-compose up -d
Enter fullscreen mode Exit fullscreen mode

💡 Fast-Track Your Project: Don't want to configure this yourself? I build custom n8n pipelines and bots. Message me with code SYS3-HUGO.

Step 6: Install and Configure Nginx (Reverse Proxy)

apt install -y nginx certbot python3-certbot-nginx
nano /etc/nginx/sites-available/n8n
Enter fullscreen mode Exit fullscreen mode

Add this config (replace automation.yourdomain.com):

server {
    listen 80;
    server_name automation.yourdomain.com;

    location / {
        proxy_pass http://localhost:5678;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_buffering off;
    }
}
Enter fullscreen mode Exit fullscreen mode

Enable the site and test:

ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/n8n
rm /etc/nginx/sites-enabled/default
nginx -t
systemctl restart nginx
Enter fullscreen mode Exit fullscreen mode

Step 7: Secure with SSL

certbot certonly --nginx -d automation.yourdomain.com
Enter fullscreen mode Exit fullscreen mode

Update your Nginx config to use the certificate:

nano /etc/nginx/sites-available/n8n
Enter fullscreen mode Exit fullscreen mode

Replace the server block with this:

server {
    listen 80;
    server_name automation.yourdomain.com;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    server_name automation.yourdomain.com;

    ssl_certificate /etc/letsencrypt/live/automation.yourdomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/automation.yourdomain.com/privkey.pem;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers HIGH:!aNULL:!MD5;

    location / {
        proxy_pass http://localhost:5678;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_buffering off;
    }
}
Enter fullscreen mode Exit fullscreen mode

Restart Nginx:

nginx -t
systemctl restart nginx
Enter fullscreen mode Exit fullscreen mode

Step 8: Access Your n8n Instance

Open your browser and go to https://automation.yourdomain.com. You'll be prompted to create an admin account. Set a strong password. This is your entire automation system.


Setting Up Contabo for n8n

Contabo VPS is almost identical to Hetzner, but with more storage. The main difference: you get 200 GB SSD on the cheapest tier instead of 25 GB.

Step 1: Deploy a Server on Contabo

Sign up at Contabo VPS. Choose:

  • VPS S ($3.99/month)
  • Ubuntu 22.04 x64
  • Add your SSH key during setup

Step 2: Connect and Initialize

ssh -i ~/.ssh/contabo_key root@your_contabo_ip
apt update && apt upgrade -y
apt install -y curl wget git nano docker.io
Enter fullscreen mode Exit fullscreen mode

Step 3: Install Docker Compose

curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
Enter fullscreen mode Exit fullscreen mode

Step 4: Deploy n8n (Same as Hetzner)

Use the exact same docker-compose.yml from the Hetzner section above. The setup is identical.

mkdir -p /home/n8n && cd /home/n8n
nano docker-compose.yml
Enter fullscreen mode Exit fullscreen mode

Paste the Docker Compose config, then:

docker-compose up -d
Enter fullscreen mode Exit fullscreen mode

Step 5: Nginx and SSL (Same as H

Top comments (0)