n8n is a modern workflow automation tool that integrates more than 300 different services and platforms. With its help, you can create complex automation scenarios without needing to write code — simply connecting nodes with visual links.
Self-hosting n8n on your own VPS gives maximum control over your automated processes. In this guide, we'll cover installing n8n using Docker — the most practical and scalable deployment method.
System Requirements
For successful installation of n8n, you'll need:
- VPS server with Linux (Ubuntu 22.04 or later is recommended)
- Account with administrative privileges (sudo)
- Docker and Docker Compose
- Minimum 1 GB RAM (2 GB or more recommended)
- Minimum 5-10 GB free disk space (20 GB or more recommended for active use)
Environment Preparation: Installing Docker
Start by connecting to the server via SSH and run the following commands to install Docker:
sudo apt update 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-compose
Verify the correct installation by checking versions:
docker --version docker-compose --version
To simplify work, add your user to the docker group:
sudo usermod -aG docker $USER
Important: After executing this command, you need to end the current SSH session and reconnect for the changes to take effect.
Quick Installation Using Docker
Creating Persistent Storage
First, create a Docker volume to save n8n settings and data:
docker volume create n8n_data
Running n8n
Execute the command to start the n8n container:
docker run -it --rm \ --name n8n \ -p 5678:5678 \ -v n8n_data:/home/node/.n8n \ docker.n8n.io/n8nio/n8n
After startup, n8n will be available through the browser at:
http://<your_VPS_IP>:5678
PostgreSQL Integration (Extended Configuration — Optional)
n8n initially works with the lightweight SQLite database, which is perfect for development and small projects. However, SQLite has performance limitations under intensive use and doesn't support concurrent operation of multiple processes.
For stable operation in production environment and ensuring scalability, you should switch to PostgreSQL — a professional relational DBMS capable of handling large data volumes and multiple connections.
PostgreSQL Setup
The first step is to deploy PostgreSQL. You can choose one of the following options:
- Installation on the same server.
- Using cloud services (ElephantSQL, AWS RDS, Google Cloud SQL).
- Deployment on a separate server.
Deploying PostgreSQL via Docker
For quick creation of a PostgreSQL instance, use the following command:
docker run --name postgres \ -e POSTGRES_USER=n8n_user \ -e POSTGRES_PASSWORD=supersecret \ -e POSTGRES_DB=n8n \ -p 5432:5432 \ -d postgres
Container parameters:
n8n_user
— database user (you can choose any name),supersecret
— access password (use a strong password),n8n
— name of the database to be created.
Connecting n8n to PostgreSQL
After starting PostgreSQL, configure n8n to work with the new database:
docker run -it --rm \ --name n8n \ -p 5678:5678 \ -e DB_TYPE=postgresdb \ -e DB_POSTGRESDB_DATABASE=n8n \ -e DB_POSTGRESDB_HOST=localhost \ -e DB_POSTGRESDB_PORT=5432 \ -e DB_POSTGRESDB_USER=n8n_user \ -e DB_POSTGRESDB_PASSWORD=supersecret \ -v n8n_data:/home/node/.n8n \ docker.n8n.io/n8nio/n8n
Environment variables description:
DB_TYPE=postgresdb
— activates PostgreSQL driver,DB_POSTGRESDB_DATABASE=n8n
— target database name,DB_POSTGRESDB_HOST=localhost
— database server host (replace with actual IP for remote deployment),DB_POSTGRESDB_PORT=5432
— PostgreSQL connection port,DB_POSTGRESDB_USER=n8n_user
— user credentials,DB_POSTGRESDB_PASSWORD=supersecret
— authentication password.
Security Recommendations
Consider the following points when configuring:
- Create unique database and user names.
- Use strong passwords to protect data.
- Verify network accessibility between n8n and PostgreSQL containers.
- When using external PostgreSQL, configure the firewall to allow incoming connections from the n8n server's IP address.
Installation via Docker Compose (Preferred Method)
Docker Compose simplifies container and configuration management. This approach is recommended for permanent operation.
Creating Configuration File
Create a Docker Compose configuration file in the nano text editor by entering the command in terminal:
nano docker-compose.yml
Insert the following configuration into the opened editor:
version: '3' services: n8n: image: docker.n8n.io/n8nio/n8n restart: always ports: - "5678:5678" environment: - GENERIC_TIMEZONE=Europe/Berlin volumes: - n8n_data:/home/node/.n8n volumes: n8n_data:
Save the file with the keyboard shortcut:
- Ctrl + O (save)
- Enter (confirm)
- Ctrl + X (exit editor)
Managing n8n
Start n8n in background mode:
docker compose up -d
Stop n8n:
docker compose down
Updating n8n to the Latest Version
To update n8n, execute the commands sequentially:
docker compose pull docker compose down docker compose up -d
Tunnel Mode: Working with External Webhooks
Purpose of Tunnel
Tunnel mode creates a temporary public HTTPS address for your local server, which is necessary for testing incoming webhooks from external services (Telegram, Stripe, Zapier, etc.), in case you don't have a domain and HTTPS.
Application
This mode is perfect for:
- Debugging webhook integrations
- Testing automation with external services
- Temporary server publication without SSL configuration
Example: if you're setting up a bot in Telegram for automatic message processing, Telegram needs to send webhooks to your server. However, without a public IP and SSL certificate, this is impossible. Tunnel mode solves this problem by providing a temporary secure URL that can be specified in Telegram bot settings.
Activating Tunnel
docker run -it --rm \ --name n8n \ -p 5678:5678 \ -v n8n_data:/home/node/.n8n \ docker.n8n.io/n8nio/n8n \ start --tunnel
Warning: Tunnel mode is intended exclusively for testing. Do not use it in production for security reasons.
Summary
You've mastered installing n8n on VPS using Docker — a reliable and flexible deployment method. Now you can create automated workflows by integrating popular services: Telegram, Google Workspace, Slack, CRM systems, and hundreds of other platforms.
n8n provides powerful capabilities for:
- Automating routine tasks
- Synchronizing data between systems
- Creating notifications and alerts
- Processing webhooks and API requests
Professional Hosting Solution for n8n
Want to avoid technical complexities? We have everything you need!
Our services:
- Optimized infrastructure: VPS and dedicated servers for n8n.
- Expert support: 24/7 assistance in Czech and English.
- Flexible plans and conditions: Configurations that match your needs.
Contact us and start automating business processes today!