best vps server

Nov 06, 2025

20 min read

Easiest Way to Install and Deploy n8n on a VPS with HTTPS

Written by

Abdelhadi Dyouri

Setting up n8n on a VPS might seem complex at first, but it's actually surprisingly straightforward! Thanks to Docker and Caddy, you can quickly deploy a production-ready n8n instance with automatic HTTPS encryption in just a few minutes.

In this comprehensive installation guide, you'll learn how to install n8n on a VPS using Docker, configure automatic SSL certificates with Caddy, and get your workflow automation platform running securely.

Easiest Way to Install and Deploy n8n on a VPS

Easiest Way to Install and Deploy n8n on a VPS with HTTPS

If you're looking for the fastest way to get n8n VPS hosting up and running on Ubuntu 24.04, here are the essential commands:

# Install Docker (follow official Docker docs)
sudo apt update

# Create n8n data volume
docker volume create n8n_data

# Run n8n container
docker run -d --rm \
 --name n8n \
 -p 5678:5678 \
 -e GENERIC_TIMEZONE="America/New_York" \
 -e TZ="America/New_York" \
 -e N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true \
 -e N8N_RUNNERS_ENABLED=true \
 -e VUE_APP_URL_BASE_API=https://n8n.yourdomain.com/ \
 -e N8N_EDITOR_BASE_URL=https://n8n.yourdomain.com/ \
 -e WEBHOOK_URL=https://n8n.yourdomain.com/ \
 -e WEBHOOK_BASE_URL=https://n8n.yourdomain.com/ \
 -e WEBHOOK_TUNNEL_URL=https://n8n.yourdomain.com/ \
 -v n8n_data:/home/node/.n8n \
 docker.n8n.io/n8nio/n8n

# Install and configure Caddy
sudo apt install caddy
sudo nano /etc/caddy/Caddyfile  # Add your configuration
sudo systemctl restart caddy

Using Caddy and Docker is the easiest way to install and deploy n8n. For detailed instructions, including configuration options and troubleshooting tips for how to install n8n on VPS, continue reading below.

Install n8n with Docker

What is n8n VPS?

Before diving into the installation, let's quickly clarify what n8n means. n8n is a powerful, open-source workflow automation tool that lets you connect different apps and services together. When you deploy n8n on a VPS (Virtual Private Server), you get complete control over your automation platform, with full data privacy, customization options, and the ability to scale as your needs grow.

Unlike cloud-hosted solutions, a VPS gives you total ownership of your data and workflows, making it perfect for businesses with specific security requirements or those who want to avoid recurring subscription costs.

n8n VPS Requirements

To follow this tutorial and successfully install n8n on a VPS, you'll need:

  • Ubuntu 24.04 with root or sudo access (If you haven't noticed, SSD Nodes offers the most affordable and reliable Ubuntu servers in the world. Our NVMe VPS options provide lightning-fast performance for your n8n workflows). You can follow this SSH guide to connect to your VPS.
  • Domain name pointing to your server's IP address (e.g., n8n.yourdomain.com)
  • Open firewall ports: 80 (HTTP), 443 (HTTPS), and 5678 (n8n default port)
  • Basic familiarity with command-line operations

Note: Before proceeding with the installation, ensure that TCP ports 80, 443, and 5678 are open on your server's firewall. Port 80 allows the initial domain verification for SSL certificates, port 443 is needed for serving encrypted HTTPS traffic, and port 5678 is n8n's default application port.

Step 1: Install Docker on Your VPS

To run n8n on your server efficiently, you'll use Docker, which provides a clean, isolated environment for your n8n instance. First, update your package repositories to ensure you're working with the latest available software:

sudo apt update

updating packages before installing n8n

Next, follow the official instructions from Docker to install Docker Engine. Docker's official documentation provides the most up-to-date and reliable installation method for Ubuntu 24.04.

After Docker is installed, add your user to the docker group (optional, but recommended to run docker without sudo):

sudo usermod -aG docker $USER
newgrp docker

This step allows you to run Docker commands without needing sudo every time, making your workflow more efficient.

Now, start and enable Docker to run automatically on system boot:

sudo systemctl start docker
sudo systemctl enable docker

You can verify Docker is running correctly by checking its status:

sudo systemctl status docker

Docker status

Step 2: Run n8n with Docker

Now that Docker is installed, it's time to deploy n8n on your VPS. First, create a persistent volume for n8n data. This ensures your workflows, credentials, and settings are preserved even if the container is stopped or restarted:

docker volume create n8n_data

Next, run the n8n container with all necessary configuration. We'll start with an interactive mode first to verify everything works:

docker run -it --rm \
 --name n8n \
 -p 5678:5678 \
 -e GENERIC_TIMEZONE="America/New_York" \
 -e TZ="America/New_York" \
 -e N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true \
 -e N8N_RUNNERS_ENABLED=true \
 -e VUE_APP_URL_BASE_API=https://n8n.yourdomain.com/ \
 -e N8N_EDITOR_BASE_URL=https://n8n.yourdomain.com/ \
 -e WEBHOOK_URL=https://n8n.yourdomain.com/ \
 -e WEBHOOK_BASE_URL=https://n8n.yourdomain.com/ \
 -e WEBHOOK_TUNNEL_URL=https://n8n.yourdomain.com/ \
 -v n8n_data:/home/node/.n8n \
 docker.n8n.io/n8nio/n8n

Important: Replace "America/New_York" with your timezone. Find yours from this page. Also, replace n8n.yourdomain.com with your actual domain name throughout all the environment variables.

You should see output indicating that the editor is now accessible:

Editor is now accessible via:
http://localhost:5678

This interactive mode (-it) is useful for testing, but for production n8n VPS hosting, you'll want to run the container in detached mode. Stop the current container (Ctrl+C) and run it again with the -d flag:

docker run -d --rm \
 --name n8n \
 -p 5678:5678 \
 -e GENERIC_TIMEZONE="America/New_York" \
 -e TZ="America/New_York" \
 -e N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true \
 -e N8N_RUNNERS_ENABLED=true \
 -e VUE_APP_URL_BASE_API=https://n8n.yourdomain.com/ \
 -e N8N_EDITOR_BASE_URL=https://n8n.yourdomain.com/ \
 -e WEBHOOK_URL=https://n8n.yourdomain.com/ \
 -e WEBHOOK_BASE_URL=https://n8n.yourdomain.com/ \
 -e WEBHOOK_TUNNEL_URL=https://n8n.yourdomain.com/ \
 -v n8n_data:/home/node/.n8n \
 docker.n8n.io/n8nio/n8n

You should receive a container ID similar to this:

af1eb22262acc60fc205b80e57ad76b3c50909f83d0036e4921db517ba95ec6f

This long alphanumeric string is your container's unique identifier, confirming that n8n is now running in the background.

To verify that n8n is running correctly, test it with curl:

curl localhost:5678

You'll see output that mentions JavaScript is required, which is perfectly normal and indicates n8n is responding:

n8n is successfully running on a VPS

This confirms that n8n is successfully running on port 5678 and ready to be accessed through a web browser.

Step 3: Install and Configure Caddy for Automatic HTTPS

Now that n8n is running, you need to set up HTTPS to secure your connection. Caddy makes this incredibly easy by automatically obtaining and renewing Let's Encrypt SSL certificates. This is one of the key advantages of this easy n8n deployment method.

First, install Caddy:

sudo apt update
sudo apt install caddy
caddy version

The caddy version command confirms that Caddy is installed correctly and shows you which version you're running:

Caddy version

Next, configure Caddy to reverse proxy requests to your n8n instance and handle SSL certificates automatically. Open the Caddyfile:

sudo nano /etc/caddy/Caddyfile

Add this configuration at the top of the file:

{
    email [email protected]
}
n8n.yourdomain.com {
    reverse_proxy localhost:5678
}

Important: Replace [email protected] with your actual email address (this is used by Let's Encrypt to send certificate expiration notices) and n8n.yourdomain.com with your actual domain name.

Your complete Caddyfile configuration should look like this:

{
    email [email protected]
}
:80 {
    # Set this path to your site's directory.
    root * /usr/share/caddy
    # Enable the static file server.
    file_server
    # Another common task is to set up a reverse proxy:
    # reverse_proxy localhost:8080
    # Or serve a PHP site through php-fpm:
    # php_fastcgi localhost:9000
}
n8n.yourdomain.com {
    reverse_proxy localhost:5678
}

Save and close the file (Ctrl+X, then Y, then Enter in nano).

Step 4: Start Caddy and Enable Automatic HTTPS

With your Caddyfile configured, it's time to start Caddy and let it work its magic. Enable and restart Caddy:

sudo systemctl restart caddy
sudo systemctl enable caddy

The restart command applies your new configuration, while enable ensures Caddy starts automatically when your server reboots.

Check if everything is working correctly:

sudo systemctl status caddy

You should see output indicating that Caddy is active and running:

● caddy.service - Caddy
     Loaded: loaded (/usr/lib/systemd/system/caddy.service; enabled)
     Active: active (running) 

If you see "active (running)" in green text, congratulations! Caddy is now running and has automatically obtained an SSL certificate for your domain.

Step 5: Access Your n8n Instance with HTTPS

Now for the moment of truth! Visit https://n8n.yourdomain.com in your browser (remember to replace with your actual domain name).

You should see:

  • Automatic HTTPS with a green lock icon in your browser's address bar.
  • n8n login/setup page ready for you to create your first account

n8n successfully running on a VPS with HTTPS

Congratulations! You've successfully deployed n8n on your VPS with automatic HTTPS encryption. Your workflow automation platform is now secure, production-ready, and accessible from anywhere in the world.

Troubleshooting Common n8n VPS Installation Issues

Even with the easiest way to deploy n8n on a VPS, you might occasionally run into issues. Here are solutions to the most common problems:

502 Bad Gateway Error

If you see a 502 Bad Gateway error when accessing your domain:

  • Check if n8n is running: docker ps (you should see the n8n container listed)
  • Check Caddy logs: sudo journalctl -u caddy -f (look for error messages)
  • Verify DNS: dig n8n.yourdomain.com (ensure your domain points to the correct IP address)

Certificate Issues

If HTTPS isn't working or you see certificate warnings:

  • Ensure your domain points to the correct IP (DNS propagation can take up to 48 hours)
  • Check ports 80 and 443 are open: sudo ufw allow 80 && sudo ufw allow 443
  • Verify the email in Caddyfile is valid (Let's Encrypt uses this for important notifications)

n8n Not Starting

If n8n refuses to start or crashes immediately:

  • Check Docker logs: docker logs n8n (this shows detailed error messages)
  • Ensure timezone is correct (invalid timezones can cause startup failures)
  • Verify port 5678 isn't blocked by your firewall or already in use by another application

Running n8n as a Permanent Service (Recommended)

The docker run command above uses the --rm flag, which means the container is removed when it stops. For a production n8n VPS setup, you'll want n8n to run permanently and restart automatically if it crashes or your server reboots.

The best way to achieve this is using Docker Compose. Create a docker-compose file:

nano docker-compose.yml

Add the following configuration:

version: '3.8'
services:
  n8n:
    image: docker.n8n.io/n8nio/n8n
    container_name: n8n
    restart: unless-stopped
    ports:
      - "5678:5678"
    environment:
      - GENERIC_TIMEZONE=America/New_York
      - TZ=America/New_York
      - N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
      - N8N_RUNNERS_ENABLED=true
      - VUE_APP_URL_BASE_API=https://n8n.yourdomain.com/
      - N8N_EDITOR_BASE_URL=https://n8n.yourdomain.com/
      - WEBHOOK_URL=https://n8n.yourdomain.com/
      - WEBHOOK_BASE_URL=https://n8n.yourdomain.com/
      - WEBHOOK_TUNNEL_URL=https://n8n.yourdomain.com/
    volumes:
      - n8n_data:/home/node/.n8n
volumes:
  n8n_data:
    external: true

Remember to replace the timezone and domain name with your actual values.

Now, if you're currently running n8n with the docker run command, stop it first:

docker stop n8n

Then start n8n using Docker Compose:

docker compose up -d

With this configuration, n8n will automatically restart if it crashes and will start automatically when your server reboots, ensuring maximum uptime for your workflows:

running n8n on a VPS with Docker Compose

What You've Accomplished

By following this guide, you've successfully:

  • Deployed n8n in Docker with persistent data storage
  • Configured automatic HTTPS with Let's Encrypt via Caddy
  • Set up auto-renewing SSL certificates (no manual renewals needed!)
  • Created a professional subdomain setup for clean, branded access
  • Built a secure, production-ready deployment that can scale with your needs

Your n8n VPS installation is now complete! You can now securely create and run workflow automations, integrate hundreds of different services, and maintain complete control over your data. With automatic HTTPS and persistent storage, you have a robust foundation for building powerful automation workflows.

FAQ

Can I install n8n on a VPS?

Absolutely! In fact, installing n8n on a VPS is one of the best ways to run n8n. It gives you complete control over your data, allows for unlimited workflows and executions (compared to cloud-hosted plans), and lets you customize your installation exactly how you need it. This tutorial shows you the easiest way to deploy n8n on VPS using Docker and Caddy.

What are the minimum n8n VPS requirements?

For basic n8n usage, you'll need at least 1GB of RAM and 10GB of storage. However, for production use, we recommend at least 2GB of RAM and 20GB of storage. The exact requirements depend on the complexity and frequency of your workflows. If you're running many simultaneous workflows or handling large amounts of data, consider upgrading to a more powerful VPS.

Is n8n VPS hosting more affordable than cloud options?

Yes, hosting n8n on your own VPS is typically much more cost-effective than cloud-hosted plans, especially as your usage grows. With a VPS, you pay a fixed monthly fee regardless of the number of workflows or executions. Plus, you get complete data ownership and privacy. Check out our affordable VPS options designed specifically for applications like n8n.

How do I secure my n8n VPS installation?

This tutorial already includes automatic HTTPS via Let's Encrypt, which encrypts all traffic to your n8n instance. Additionally, make sure to: create a strong password for your n8n account, keep Docker and your VPS updated with security patches, configure firewall rules to only allow necessary ports, and consider setting up automated backups of your n8n_data volume.

How do I backup my n8n workflows and data?

Your n8n data is stored in the Docker volume named n8n_data. You can back up this volume using Docker commands or by backing up the volume's location on disk (typically /var/lib/docker/volumes/n8n_data). For automated backups, consider setting up a cron job that regularly copies this data to a secure location or cloud storage service.

What happens when my Let's Encrypt certificate expires?

Nothing! That's the beauty of using Caddy for your n8n VPS hosting. Caddy automatically renews your Let's Encrypt certificates before they expire (typically renewing at 30 days before expiration for 90-day certificates). You don't need to do anything manually. Just ensure your server stays online and connected to the internet, and Caddy handles the rest.

A note about tutorials: We encourage our users to try out tutorials, but they aren't fully supported by our team—we can't always provide support when things go wrong. Be sure to check which OS and version it was tested with before you proceed.

If you want a fully managed experience, with dedicated support for any application you might want to run, contact us for more information.

Leave a Reply