How to Host n8n on an Ubuntu VPS Using Docker Print

  • self hosted n8n, docker, automation server, workflow automation, n8n self hosting, install n8n, n8n, n8n ssl, n8n vps, n8n docker compose, n8n hosting, linux vps, kvm vps, n8n ubuntu, ubuntu vps, n8n docker
  • 0

Want to self-host n8n on an Ubuntu VPS? You can run your own workflow automation server using Docker Compose, with a custom domain, free SSL certificate, and persistent storage.

This guide explains how to install n8n on Ubuntu 24.04 LTS using Docker, configure HTTPS, and access your automation workflows securely. The same general procedure can be used on Ubuntu 26.04 where Docker is supported.

Self-hosting n8n on a VPS gives you control over your automation infrastructure, application configuration, and stored workflow data.

Need a VPS for n8n? Owned Networks offers Linux KVM VPS hosting with full root access, SSD storage, DDoS protection, and US/EU server locations.

Before You Start

You'll need:

  • Ubuntu 24.04 LTS VPS with root or sudo access.
  • A domain or subdomain such as n8n.example.com.
  • At least 2 GB RAM for a small deployment; 4 GB or more is preferable for additional workloads.
  • An A record pointing your subdomain to the VPS public IPv4 address.
  • Ports 80 and 443 accessible for HTTPS.
  • A fresh server or an existing Docker installation without conflicting web services.

Tip: For heavier automation, AI workflows, multiple users, or production workloads, select a VPS with additional CPU and RAM. See our KVM VPS plans and pricing.

Step 1: Update Ubuntu and Install Docker

Connect to your VPS through SSH and update Ubuntu:

sudo apt update && sudo apt upgrade -y
sudo apt install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

Add Docker's official Ubuntu repository:

sudo tee /etc/apt/sources.list.d/docker.sources > /dev/null <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF

sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl enable --now docker

Note: These instructions assume a fresh Ubuntu VPS without conflicting Docker packages. If Docker is already installed, check its installation before changing repositories.

Verify Docker and Docker Compose:

sudo docker --version
sudo docker compose version

Step 2: Create the n8n Docker Compose Configuration

Create a directory for n8n:

sudo mkdir -p /opt/n8n
cd /opt/n8n

Create the Docker Compose configuration:

sudo tee compose.yaml > /dev/null <<'EOF'
services:
  n8n:
    image: docker.n8n.io/n8nio/n8n:stable
    restart: unless-stopped
    environment:
      - N8N_HOST=n8n.example.com
      - N8N_PROTOCOL=https
      - N8N_EDITOR_BASE_URL=https://n8n.example.com/
      - N8N_WEBHOOK_URL=https://n8n.example.com/
      - N8N_PROXY_HOPS=1
      - GENERIC_TIMEZONE=UTC
      - TZ=UTC
      - N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
    volumes:
      - n8n_data:/home/node/.n8n

  caddy:
    image: caddy:2
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile:ro
      - caddy_data:/data
      - caddy_config:/config
    depends_on:
      - n8n

volumes:
  n8n_data:
  caddy_data:
  caddy_config:
EOF

Important: Replace every occurrence of n8n.example.com with your actual domain or subdomain before starting the containers.

The n8n_data volume preserves workflow data, credentials, and the encryption key across container restarts. This example uses n8n's built-in SQLite database, suitable for starting with smaller deployments. For larger production environments, consider PostgreSQL and additional backup procedures.

Step 3: Configure Your Domain and Free SSL

Create the Caddy reverse proxy configuration:

sudo tee /opt/n8n/Caddyfile > /dev/null <<'EOF'
n8n.example.com {
    reverse_proxy n8n:5678
}
EOF

Replace n8n.example.com with your domain in both configuration files.

Make sure the domain's DNS A record points to your VPS public IP address. If you have an AAAA record, it must also point to a reachable IPv6 address on your server.

Allow ports 80 and 443 through any active host or provider firewall. If using UFW, you can run:

sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw status

Do not enable or reset UFW without first confirming that your SSH port is permitted.

Caddy will automatically request and manage an HTTPS certificate when DNS and network connectivity are configured correctly. No separate Certbot installation is required.

Step 4: Start n8n Using Docker Compose

Start the n8n and Caddy containers:

cd /opt/n8n
sudo docker compose config
sudo docker compose up -d
sudo docker compose ps

If the containers start correctly, open your domain in a browser:

https://n8n.example.com

You should see the n8n initial setup screen. Create your administrator account and begin building workflows.

Security: Do not expose n8n's internal port 5678 directly to the public internet. In this configuration, external HTTPS traffic reaches n8n through Caddy.

Step 5: Verify and Manage Your n8n Server

Check running containers and view application logs:

cd /opt/n8n
sudo docker compose ps
sudo docker compose logs --tail=50 n8n
sudo docker compose logs --tail=50 caddy

To restart the services:

sudo docker compose restart

How to Update n8n Docker

Before updating, back up your n8n data, credentials encryption key, and configuration files. Review the official n8n documentation for version-specific changes.

To pull newer container images and recreate the services:

cd /opt/n8n
sudo docker compose pull
sudo docker compose up -d
sudo docker compose ps

For production servers, pin tested image versions instead of automatically adopting newer versions. Always maintain verified backups before upgrading.

Troubleshooting n8n on Ubuntu VPS

n8n Website Not Loading

Verify that the containers are running, your DNS records point to the correct VPS, and ports 80 and 443 are accessible. Check logs:

sudo docker compose ps
sudo docker compose logs --tail=100

n8n SSL Certificate Not Working

Confirm your domain resolves correctly, ports 80 and 443 are reachable, and no other application is using those ports. Check Caddy logs with sudo docker compose logs caddy.

n8n Webhooks Not Working

Verify that N8N_WEBHOOK_URL matches your public HTTPS domain and N8N_PROXY_HOPS=1 is configured. Also ensure HTTPS is working and your external service is using the correct webhook URL.

Docker Permission Denied

Use sudo docker for commands unless your user has been specifically configured for Docker access. Docker group membership effectively grants root-level control of the host.

Related Solution: Host n8n on an Owned Networks KVM VPS

Need a VPS for n8n Automation?

Run n8n on your own Linux VPS with full root access and control over your Docker containers, workflows, and hosting environment.

  • KVM virtualization and SSD storage
  • Full root access for Docker and n8n
  • DDoS protection included
  • New York, Miami, Dallas, Los Angeles, Seattle, London, and Amsterdam
  • Flexible VPS resources for automation workloads

Compare KVM VPS Plans and Pricing

Explore VPS Locations

Frequently Asked Questions

Can I self-host n8n on a VPS?

Yes. You can self-host n8n on an Ubuntu VPS using Docker Compose. A VPS provides a persistent server environment for running workflows, webhooks, and automations.

How much RAM does n8n need on a VPS?

A small n8n deployment may run with approximately 2 GB RAM, depending on workload. For additional workflows, AI services, or higher execution volume, 4 GB or more is a sensible starting point. Resource needs depend on your actual workload.

Is n8n free to self-host?

n8n offers a self-hosted Community Edition. You still pay for VPS infrastructure and any external services or APIs used by your workflows. Some features require a commercial license.

Can I install n8n with Docker Compose?

Yes. Docker Compose is a convenient way to configure n8n, persistent storage, environment variables, and an HTTPS reverse proxy.

Do I need a domain for n8n?

A domain is strongly recommended for HTTPS, OAuth callbacks, and public webhooks. This guide uses a subdomain with Caddy to provide automatic SSL certificates.

Should I use SQLite or PostgreSQL for n8n?

SQLite is convenient for small deployments. PostgreSQL is generally preferable for larger production installations with more workflows, users, or database activity.

Can I host n8n on Ubuntu 26.04?

Yes, provided the required Docker components are supported and properly installed. The container-based deployment process is similar to Ubuntu 24.04.

How do I back up my self-hosted n8n?

Back up the persistent n8n Docker volume, database, and Compose configuration. Preserve the credentials encryption key because losing it may make stored credentials unreadable. Test restoration before relying on a backup.

Conclusion

Self-hosting n8n on an Ubuntu VPS using Docker Compose gives you a flexible automation platform with a custom domain, HTTPS, and persistent workflow storage.

For hosting, testing, or production automation workloads, explore Owned Networks Linux VPS Hosting or compare our KVM VPS plans.

Last reviewed: November 2026. References: n8n Documentation and Docker Installation for Ubuntu.


Was this answer helpful?

KVM VPS & Dedicated Servers

Deploy a Linux VPS in under 2 minutes — AlmaLinux, Rocky Linux, Ubuntu, Debian. Full root access, KVM virtualization, US and EU locations.

« Back