sanjaysikdar.dev

Blog

HomeAboutTools
Sanjay Sikdar

Sanjay Sikdar

Software developer who enjoys developing software, solving challenges, and programming.

GithubLinkedInMain SiteSitemapRSS

© 2026 All rights reserved. Sanjay Sikdar

dockerdevopsubuntulinuxautomationworkflow

Self host n8n on Ubuntu 24 (Docker)

Sanjay Sikdar

Sanjay Sikdar

·Dec 25, 2025·3 min read
Self host n8n on Ubuntu 24 (Docker)

A simple, step-by-step guide to self-host n8n on Ubuntu 24.04 using Docker

If you want your own automation server (like Zapier, but self-hosted), n8n is perfect.

This guide is step-by-step and covers:

  • Install Docker on Ubuntu 24.04
  • Run n8n locally (fastest)
  • Run n8n production-style with HTTPS + domain using Docker

Step 1 — Creating an EC2 Instance, DNS and SSH

First, we require an ec2 instance so launch an instance with your preferred size, you can also attach an Elastic IP to your instance.

In your DNS Server (Route 53 or Cloudflare) add these records.

Record NameRecord TypeValue
n8nA[Server_IP]
Now, we have pointed from our DNS to our new server IP, now we need to log in into our new server using SSH client.

Example: ssh -i "YourKey.pem" ubuntu@SERVER_IP

Step 2 — Setup and Installing Requirements

Set a Timezone on Ubuntu:

bash
sudo timedatectl
sudo timedatectl set-timezone Asia/Kolkata

If first time using apt in this session, run the update command to update the package manager cache:

bash
sudo apt update -y

Step 3 — Install Docker

Following Official Docs: https://docs.docker.com/engine/install/ubuntu

Set up Docker's apt repository

bash
# Add Docker's official GPG key:
sudo apt update
sudo apt install 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 the repository to Apt sources:
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Signed-By: /etc/apt/keyrings/docker.asc
EOF
 
sudo apt update

Install the Docker packages.

bash
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
 
sudo systemctl status docker

To Test

bash
sudo docker run hello-world
sudo docker version

Step 4 — Test Run and Start n8n in Detached Mode

bash
sudo docker run -it --rm \
 --name n8n \
 -p 5678:5678 \
 -e GENERIC_TIMEZONE="Asia/Kolkata" \
 -e TZ="Asia/Kolkata" \
 -e N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true \
 -e N8N_RUNNERS_ENABLED=true \
 -v n8n_data:/home/node/.n8n \
 docker.n8n.io/n8nio/n8n

You will see a message indicating that n8n is running on port 5678.

  • Replace the timezone with your own if needed.
  • Allow port 5678 in your firewall.
  • Open your browser and visit: http://YOUR-SERVER-IP:5678

Once you have confirmed that n8n is working correctly, start it in detached mode using the command below:

bash
sudo docker run -d \
 --name n8n \
 --restart unless-stopped \
 -p 127.0.0.1:5678:5678 \
 -e GENERIC_TIMEZONE="Asia/Kolkata" \
 -e TZ="Asia/Kolkata" \
 -e N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true \
 -e N8N_RUNNERS_ENABLED=true \
 -e N8N_HOST="n8n.example.com" \
 -e N8N_PROTOCOL="https" \
 -e WEBHOOK_URL="https://n8n.example.com/" \
 -e N8N_PROXY_HOPS=1 \
 -e N8N_EDITOR_BASE_URL="https://n8n.example.com/" \
 -v n8n_data:/home/node/.n8n \
 docker.n8n.io/n8nio/n8n
 
  • Update the domain and timezone as per your setup.

Step 5 — Create Nginx reverse proxy config (with WebSocket support)

Install Nginx:

bash
sudo apt install nginx
sudo apt install certbot python3-certbot-nginx
bash
sudo nano /etc/nginx/sites-available/n8n
bash
# WebSocket upgrade mapping
map $http_upgrade $connection_upgrade {
  default upgrade;
  ''      close;
}
 
server {
  listen 80;
  server_name n8n.example.com;
 
  location / {
    proxy_pass http://127.0.0.1:5678;
 
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $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_read_timeout 3600;
    proxy_send_timeout 3600;
  }
}
bash
sudo ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/
 
sudo nginx -t
sudo systemctl reload nginx
sudo systemctl status nginx

Step 5.1 — Installing SSL

bash
sudo certbot --nginx -d n8n.example.com
 
sudo systemctl status certbot.timer
sudo certbot renew --dry-run

Now, you can request to your domain (http://n8n.example.com)

Sanjay Sikdar

Written by Sanjay Sikdar

Software developer who enjoys developing software, solving challenges, and programming.