How to Self-Host n8n on a DigitalOcean Droplet (Step-by-Step Guide) | Code Boost
Description: Looking for a powerful, budget-friendly way to run your automations without limits? Self-hosting n8n on a DigitalOcean Droplet gives you full control, unlimited workflows, and major cost savings compa

Article

# How to Self-Host n8n on a DigitalOcean Droplet (Step-by-Step Guide)

By Matt · Jun 5, 2025

Looking for a powerful, budget-friendly way to run your automations without limits? Self-hosting n8n on a DigitalOcean Droplet gives you full control, unlimited workflows, and major cost savings compared to cloud-based automation tools like Zapier or Make. This guide walks you through everything you need — from creating your Droplet to getting n8n running with HTTPS in under 30 minutes.

## Why Self-Host n8n on DigitalOcean?

Most automation platforms charge per "task" or "operation" — at scale, this gets expensive fast. With self-hosted n8n on DigitalOcean:

- ✅ Unlimited workflows — no monthly execution caps
- ✅ Low cost — as little as $6/month for a Basic Droplet
- ✅ Full control — your data, your infrastructure, your custom integrations
- ✅ Persistent storage — workflows and credentials saved, unlike free cloud tiers
- ✅ Data privacy — sensitive data never leaves your server

A team running 50,000 Zapier tasks/month at $50/month would pay $600/year. The equivalent self-hosted n8n setup costs $72/year on DigitalOcean — and scales with no per-execution fees.

## Recommended Setup

### Choose a DigitalOcean Droplet

For most n8n workloads, the Basic Droplet is sufficient to start:

- Ubuntu 22.04 LTS
- 1 vCPU / 1 GB RAM — $6/month
- 25 GB SSD
- 1 TB outbound transfer included

For higher-volume workflows with many concurrent executions, upgrade to 2 GB RAM ($12/month). n8n's memory usage grows with complex workflows running in parallel.

> ✨ Use this link to create your DigitalOcean account and get $200 in free credits

> ### Claim Your $200 DigitalOcean Credit Here

## Step-by-Step: Install n8n on a DigitalOcean Droplet

### Step 1: Create Your Droplet

1. Log in to DigitalOcean (or create an account with $200 credit)
2. Click Create → Droplets
3. Select Ubuntu 22.04 LTS as the OS
4. Choose the Basic Shared CPU plan — 1 vCPU / 1 GB RAM ($6/month)
5. Select a data center region close to your users
6. Add your SSH public key for authentication (recommended over password)
7. Click Create Droplet — your server is ready in about 60 seconds

### Step 2: SSH Into the Server

    ssh root@your_droplet_ip

### Step 3: Install Docker and Docker Compose

    sudo apt update && sudo apt upgrade -y
    sudo apt install docker.io docker-compose -y
    sudo systemctl enable docker --now

Verify Docker is running:

    docker --version
    docker-compose --version

### Step 4: Set Up Your n8n Environment

Create a directory for n8n and its data:

    mkdir ~/n8n && cd ~/n8n

Create a `docker-compose.yml` file:

    version: "3"
    services:
      n8n:
        image: n8nio/n8n
        restart: always
        ports:
          - "5678:5678"
        environment:
          - N8N_BASIC_AUTH_ACTIVE=true
          - N8N_BASIC_AUTH_USER=admin
          - N8N_BASIC_AUTH_PASSWORD=yourStrongPassword123
          - N8N_HOST=yourdomain.com
          - WEBHOOK_TUNNEL_URL=https://yourdomain.com
          - N8N_PROTOCOL=https
        volumes:
          - ./n8n-data:/home/node/.n8n

Important: Replace `yourStrongPassword123` with a strong unique password and `yourdomain.com` with your actual domain. Store the password in a password manager.

Start n8n:

    docker-compose up -d

Check it's running:

    docker-compose ps
    docker-compose logs

### Step 5: Point Your Domain to the Droplet

In your domain registrar's DNS settings (or DigitalOcean's managed DNS), add an A record:

- Type: A
- Name: n8n (or @ for root domain)
- Value: your Droplet's IP address
- TTL: 3600

DNS propagation typically takes a few minutes to an hour.

### Step 6: Set Up HTTPS with Caddy (Recommended)

Caddy automatically obtains and renews Let's Encrypt SSL certificates — far simpler than configuring NGINX with Certbot.

Install Caddy:

    sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
    curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
    curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
    sudo apt update
    sudo apt install caddy

Configure your domain in `/etc/caddy/Caddyfile`:

    yourdomain.com {
      reverse_proxy localhost:5678
    }

Restart Caddy:

    sudo systemctl restart caddy

Caddy automatically requests and renews your SSL certificate. Visit `https://yourdomain.com` and n8n should load with a valid HTTPS connection.

## Securing Your n8n Instance

### Firewall Setup

Restrict server access to only the ports you need:

    sudo ufw allow OpenSSH
    sudo ufw allow 80
    sudo ufw allow 443
    sudo ufw enable

This allows SSH (22), HTTP (80 for Caddy redirects), and HTTPS (443). Port 5678 is not exposed directly — Caddy handles HTTPS termination and proxies to n8n internally.

### Updating n8n

Pull the latest n8n image and restart:

    cd ~/n8n
    docker-compose pull
    docker-compose up -d

Your workflow data is stored in the `./n8n-data` volume and persists across updates.

## Backup Your n8n Data

Before any updates or changes, take a DigitalOcean Droplet snapshot (Droplets → your droplet → Snapshots). For automated backups, copy the `~/n8n/n8n-data` directory to DigitalOcean Spaces or another remote storage location:

    # Manual backup of n8n data directory
    tar -czf n8n-backup-$(date +%Y%m%d).tar.gz ~/n8n/n8n-data

## Ready to Power Up Your Automation?

### Get $200 in Free DigitalOcean Credits

Launch your n8n server today for free with our referral link:

> ### ✨ Click Here to Launch Your Own Droplet →

### Prefer n8n's Managed Cloud?

If you'd rather not manage infrastructure, n8n Cloud handles hosting, updates, and SSL for you.

Try n8n Cloud free using this link.

## Frequently Asked Questions

### How much RAM does n8n need to run on DigitalOcean?

The 1 GB RAM Basic Droplet ($6/month) works well for small-to-medium workloads — a few dozen workflows running occasional jobs. For high-frequency workflows, many concurrent executions, or complex AI agent workflows, upgrade to 2 GB RAM ($12/month). You can resize your Droplet anytime without losing data.

### Is n8n self-hosting free for commercial use?

Yes. n8n uses a Fair-code license that permits commercial use when self-hosting. You pay only for the server infrastructure (DigitalOcean costs). Paid n8n plans cover the managed cloud service and enterprise features like Git sync and SSO.

### How do I keep n8n updated on my Droplet?

Run `docker-compose pull && docker-compose up -d` from your n8n directory. This pulls the latest n8n Docker image and restarts the container. Your workflow data in the `n8n-data` volume persists across updates. Subscribe to n8n's GitHub releases to know when updates ship.

### Can I use a subdomain for n8n (like n8n.mysite.com)?

Yes, and it's recommended. Create an A record pointing `n8n.yourdomain.com` to your Droplet IP. Update the Caddyfile to use `n8n.yourdomain.com` instead of the root domain. Update the `N8N_HOST` and `WEBHOOK_TUNNEL_URL` environment variables in your docker-compose.yml to match, then restart with `docker-compose up -d`.

### What happens to my workflows if I restart the Droplet?

Your workflows are stored in the `./n8n-data` volume directory, not in the container itself. The `restart: always` setting in docker-compose.yml ensures n8n restarts automatically after a Droplet reboot. Your data is safe as long as the volume directory exists on the server's disk.

### Should I use NGINX or Caddy for the reverse proxy?

Caddy is strongly recommended for simplicity. It automatically handles Let's Encrypt certificate issuance and renewal with a minimal configuration file. NGINX requires more configuration steps and manual Certbot setup. The only reason to choose NGINX is if you're already running it for other services on the same Droplet and want to consolidate.