n8n Installation & Configuration on Ubuntu 22.04
VM Configuration for n8n (Ubuntu 22.04)
OS
Ubuntu Server 22.04 LTS (64-bit)
CPU
Minimum 2 vCPU (Recommended: 2–4 cores)
RAM
Minimum 4 GB (Recommended: 4–8 GB)
Storage
Minimum 20 GB (Recommended: 40–50 GB SSD)
Network
Static/Private IP (Example: 172.83.83.77)
Required Ports
5678 (n8n UI), 22 (SSH), 80/443 (Optional for HTTPS)
Timezone
Asia/Kolkata (via system or environment)
Required Software
Docker Engine
Latest stable (≥20.x)
Docker Compose
Version 2.x or above
Git & Curl
Installed for basic system and Docker setup
Security & Firewall (if you want to enable ufw, optional):
sudo ufw allow 22       # SSH
sudo ufw allow 5678     # n8n Web Interface
sudo ufw allow 80,443   # Only if using HTTPS/Reverse Proxy
sudo ufw enableSteps for n8n Installation & Configuration:
1. Prepare Your Ubuntu 22.04 VM
Update your system:
sudo apt update && sudo apt upgrade -y
2. Install Docker and Docker Compose Install Docker Engine:
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.ioInstall Docker Compose:
sudo apt install -y docker-composeVerify Docker & Docker Compose Installation
2.1: Check if Docker Service is Running
sudo systemctl status dockerExpected Result:
Docker service should show active (running)
If it’s not running, start it using:
sudo systemctl start docker
2.2: Verify Docker Version
docker --versionExpected Result:
Displays the installed Docker version (e.g., Docker version 28.x.x)
2.3: Verify Docker Compose Version
For standalone Docker Compose:
docker-compose --versionExpected Result:
Shows the installed Docker Compose version.

2.4: Check Running Containers (Optional but Useful)
docker psExpected Result:
Lists all currently running Docker containers .

Allow your user to run Docker without sudo:
sudo usermod -aG docker $USER
exec sg docker newgrp3. Configure n8n with Docker Compose
Create a directory for n8n:
mkdir ~/n8n-compose
cd ~/n8n-composeCreate a docker-compose.yml file:
sudo nano docker-compose.ymlPaste the following configuration inside the file:
version: "3.1"
services:
  n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: always
    ports:
      - "5678:5678"
    environment:
      - GENERIC_TIMEZONE=Europe/Berlin      # Set your timezone
      - TZ=Europe/Berlin
      - N8N_BASIC_AUTH_ACTIVE=true          # Optional: enable basic auth
      - N8N_BASIC_AUTH_USER=admin           # Optional: set username
      - N8N_BASIC_AUTH_PASSWORD=hello@123   # Optional: set password
      - N8N_SECURE_COOKIE=false
      - DB_TYPE=sqlite
      - N8N_HOST=0.0.0.0
      - N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
      - N8N_RUNNERS_ENABLED=true
    volumes:
      - n8n_data:/home/node/.n8n
volumes:
  n8n_data:save the file in nano.
Press CTRL + O → then press Enter to save
Press CTRL + X to exit nano
Start n8n: This command starts n8n in the background using Docker Compose.
docker-compose up -d
4. Optional (Only if UFW is active): Allow Port 5678
Before allowing the port, first check if UFW (firewall) is active:
sudo ufw statusIf the status is active, then allow port 5678 for n8n:
sudo ufw allow 5678If UFW is inactive, you can skip this step.
5. Access n8n:
Open your browser and go to http://<your_vm_ip>:5678 you will see one of the following screens, depending on settings:
Case 1: Basic Authentication Enabled (Your YAML file has this )
You will first see a popup like this:
🔐 Authentication Required
Username:
Password:Here you have to enter the credentials you added in the docker-compose.yml:
Username:
adminPassword:
hello@123
Case 2: n8n Setup Page (Owner Account Creation)
After entering Basic Auth credentials, you will see a screen asking:
Email Address                         #Your email (e.g., your_company_email)
First Name                            #Your name
Last Name                             #Your surname
Password (set for n8n Admin Account)  # A new secure password for your admin loginClick "Next".
This creates your n8n Owner Account.

After Account Creation You’ll land on the n8n Main Dashboard (Workflow Editor).

From here, you can:
Create workflows
Add triggers (like Webhook, Cron, Gmail, Slack, etc.)
Automate tasks visually.
Last updated