How to Install, Configure, and Use n8n on Ubuntu (Complete Workflow Automation Guide)
Last Updated: July 11th, 2026
This comprehensive tutorial shows you how to install, configure, secure, and use n8n on an Ubuntu server. n8n is a powerful, fair-code workflow automation tool that lets you connect different web applications, APIs, and data sources together. With n8n, you can build complex, automated business processes, synchronize databases, manage alerts, and build custom AI-driven agents visually, all while keeping your data under your self-hosted control.
What Is n8n?
n8n is an extensible workflow automation platform functionally similar to commercial services like Zapier or Make, but designed with a fair-code model that allows self-hosting. Proprietary automation platforms charge per execution step or retain your private operational data on third-party clouds. By self-hosting n8n on your own Ubuntu infrastructure, you gain unlimited workflow executions, absolute privacy for credentials and payloads, and the ability to execute custom JavaScript/Python code natively inside your pipelines.
n8n Features
- Visual Node-Based Editor: Connect hundreds of pre-built integrations (like Slack, GitHub, PostgreSQL, OpenAI, and HTTP requests) using an intuitive drag-and-drop interface.
- Advanced Error Handling & Retries: Configure customized branch paths to handle failures, timeouts, and data validation errors gracefully.
- Native AI Capabilities: Build sophisticated AI chains, retrieval-augmented generation (RAG) tools, and autonomous agent loops using LangChain nodes.
- Custom Code Execution: Write inline JavaScript or Python expressions to transform, clean, and manipulate complex JSON data arrays on the fly.
- Secure Credential Management: Encrypt and manage external API keys, OAuth tokens, and database passwords securely within your instance.
Requirements & Prerequisites
You will need an Ubuntu server (22.04, 24.04 LTS, or newer) with administrative sudo privileges, Docker and Docker Compose installed, a valid domain name, and an active TLS/SSL certificate (Let's Encrypt). n8n relies on webhook endpoints and secure token exchanges, meaning an HTTPS configuration is mandatory for production use.
Step 1: Install Docker and Docker Compose
Running n8n via Docker is the recommended approach for stability and isolation. Log into your Ubuntu server and install Docker:
sudo apt update
sudo apt install -y docker.io docker-compose-v2
sudo systemctl start docker
sudo systemctl enable docker
Step 2: Create a Docker Compose Configuration for n8n
Create a dedicated directory for your automation engine and configure your environment storage mapping:
mkdir -p ~/n8n && cd ~/n8n
sudo nano docker-compose.yml
Paste the following production container configuration into the file (be sure to replace n8n.example.com with your actual domain):
services:
n8n:
image: n8nio/n8n:latest
container_name: n8n
restart: always
ports:
- 127.0.0.1:5678:5678
environment:
- N8N_HOST=n8n.example.com
- WEBHOOK_URL=https://n8n.example.com/
- N8N_ENCRYPTION_KEY=SuperSecureRandomEncryptionKeyChangeThis123
volumes:
- n8n_data:/home/node/.n8n
volumes:
n8n_data:
Save and close the file, then spin up your container in the background:
sudo docker compose up -d
Step 3: Configure an Nginx Reverse Proxy
Route public requests securely from your custom automation domain (e.g., n8n.example.com) to the local container port 5678, making sure to accommodate long-running executions and webhooks:
sudo apt install -y nginx
sudo nano /etc/nginx/conf.d/n8n.conf
Add the following server block configuration:
server {
listen 80;
server_name n8n.example.com;
client_max_body_size 64M;
location / {
proxy_pass http://127.0.0.1:5678;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header 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_buffering off;
proxy_read_timeout 300s;
proxy_connect_timeout 300s;
proxy_send_timeout 300s;
}
}
Test syntax and reload Nginx:
sudo nginx -t
sudo systemctl reload nginx
Step 4: Secure with Let’s Encrypt HTTPS
Obtain an official SSL/TLS certificate via Certbot:
sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx --agree-tos --redirect --email [email protected] -d n8n.example.com
Step 5: Initial Setup & Basic Usage Inside n8n
Open your browser and navigate to https://n8n.example.com. On your first arrival, complete the owner account registration form to lock down your n8n configuration dashboard.
- Creating Your First Workflow: Click **+ Add workflow** in the top right. You will see a blank canvas with a central starting point node.
- Adding a Trigger Node: Click the plus sign (+) to add your first node. Search for a trigger component, such as the *Webhook* trigger or a *Schedule* trigger (which runs workflows periodically on a timer). Configure the node properties (e.g., setting the interval to run every hour).
- Adding an Action Node: Click the output handle of your trigger node and add a secondary action component, such as an *HTTP Request* node or an integration like *Slack* or *Gmail*. Configure your authorization credentials under the credential dropdown inside the node parameters.
- Testing and Execution: Click the **Test step** or **Execute workflow** button on your canvas to verify data flow, inspect individual JSON response items in real-time, and toggle your workflow state to **Active** when ready for production operation.