n8n Setup: Step-by-Step Automation Guide with Docker
What will you learn in this guide?
In this guide, you will learn how to install the n8n automation platform on your own Ubuntu server with Docker Compose.
You will ensure data persistence with PostgreSQL and secure it with Nginx and SSL.
🧠 Technical Analysis and Summary
This guide covers installing the open source workflow automation platform n8n on Ubuntu using Docker Compose.
The goal is to create a self-hosted, secure and low-cost alternative to services like Zapier and Make.
Steps followed:
- Docker and Docker Compose installation
- PostgreSQL and n8n service configuration
- HTTPS with Nginx + Let's Encrypt
- Creating the first workflow
1️⃣ Preparation and Docker Installation
Docker is used to run n8n stably and sustainably.
sudo apt update && sudo apt install docker.io docker-compose -y
- This command installs the Docker engine and Compose plugin.
2️⃣ Docker Compose Configuration
- PostgreSQL is used for n8n data.
mkdir ~/n8n && cd ~/n8n
nano docker-compose.yml
- This command creates the project directory and opens the configuration file.
version: '3.7'
services:
db:
image: postgres:14
environment:
POSTGRES_USER: n8n
POSTGRES_PASSWORD: n8n_parola
POSTGRES_DB: n8n
volumes:
- postgres_data:/var/lib/postgresql/data
n8n:
image: n8nio/n8n
ports:
- "5678:5678"
environment:
DB_TYPE: postgresdb
DB_POSTGRESDB_HOST: db
DB_POSTGRESDB_USER: n8n
DB_POSTGRESDB_PASSWORD: n8n_parola
N8N_HOST: n8n.ornek.com
WEBHOOK_TUNNEL_URL: https://n8n.ornek.com
depends_on:
- db
volumes:
- n8n_data:/home/node/.n8n
volumes:
postgres_data:
n8n_data:
- This structure establishes a permanent and secure connection between n8n and the database.
3️⃣ Starting Services
docker-compose up -d
- This command starts all services in the background.
Access from browser:
http://sunucu-ip-adresi:5678
4️⃣ Security with Nginx and SSL (HTTPS)
- Using HTTP in a production environment is not recommended.
sudo apt install nginx certbot python3-certbot-nginx -y
- This command installs Nginx and Let's Encrypt tools.
sudo certbot --nginx -d n8n.ornek.com
- This process generates a free SSL certificate for your domain name.
❓ Frequently Asked Questions (FAQ)
-
Is n8n completely free? It is fair-code licensed. Personal and internal use is free.
-
Is it mandatory to use PostgreSQL? Highly recommended for production environment.
-
Why self-hosted instead of n8n Cloud? Provides lower cost and full data control.
| Error | Possible Cause | Solution |
|---|---|---|
| 401 Unauthorized | Authentication error | Check environment variables |
| Webhook not working | Wrong URL | Use domain name starting with HTTPS |
| Memory error | Insufficient RAM | Increase memory limit with NODE_OPTIONS |
Result
You can save serious time by automating your workflows with n8n. Docker-based installation provides a secure and maintainable structure.
You can immediately publish your n8n infrastructure on GenixNode.

