Install n8n Workflow Automation on VPS
n8n is a visual workflow automation tool that's free to use when self-hosted. It connects with 400+ services like Gmail, Slack, Airtable, MySQL, HTTP requests, and Telegram. You drag and drop nodes in a visual editor without writing any code. It's ideal for automating repetitive tasks such as syncing data, sending daily reports, or notifying when events occur.
Install n8n with Docker Compose
mkdir -p ~/n8n
cd ~/n8n
cat > docker-compose.yml << 'EOF'
version: "3.8"
services:
n8n:
image: docker.n8n.io/n8nio/n8n:latest
container_name: n8n
restart: unless-stopped
ports:
- "5678:5678"
environment:
N8N_HOST: automation.yourdomain.com
N8N_PORT: 5678
N8N_PROTOCOL: https
NODE_ENV: production
WEBHOOK_URL: https://automation.yourdomain.com/
GENERIC_TIMEZONE: Asia/Bangkok
N8N_BASIC_AUTH_ACTIVE: "true"
N8N_BASIC_AUTH_USER: admin
N8N_BASIC_AUTH_PASSWORD: strongpassword123
volumes:
- n8n_data:/home/node/.n8n
user: "1000:1000"
volumes:
n8n_data:
EOF
docker compose up -d
Set Up Nginx + SSL
sudo certbot --nginx -d automation.yourdomain.com
sudo nano /etc/nginx/sites-available/n8n
server {
listen 443 ssl;
server_name automation.yourdomain.com;
ssl_certificate /etc/letsencrypt/live/automation.yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/automation.yourdomain.com/privkey.pem;
location / {
proxy_pass http://localhost: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;
chunked_transfer_encoding on;
proxy_buffering off;
}
}
sudo nginx -t && sudo systemctl reload nginx
Create Your First Workflow
# Open https://automation.yourdomain.com
# Login with Basic Auth
# Example workflow: Daily report to Telegram
# 1. Node: Schedule Trigger (every day 09:00)
# 2. Node: HTTP Request (GET /api/stats)
# 3. Node: Telegram (send message with data)
# Example webhook workflow:
# 1. Node: Webhook (POST /webhook/new-order)
# 2. Node: MySQL (add data to DB)
# 3. Node: Send Email (notify team)
Set Up PostgreSQL Database (for production)
# Add to docker-compose.yml
postgres:
image: postgres:15-alpine
restart: unless-stopped
environment:
POSTGRES_DB: n8n
POSTGRES_USER: n8n
POSTGRES_PASSWORD: n8ndbpass123
volumes:
- postgres_data:/var/lib/postgresql/data
# Add env to n8n service:
DB_TYPE: postgresdb
DB_POSTGRESDB_HOST: postgres
DB_POSTGRESDB_DATABASE: n8n
DB_POSTGRESDB_USER: n8n
DB_POSTGRESDB_PASSWORD: n8ndbpass123
n8n is excellent for VPS deployments that run business automation 24/7. If you're looking for a Thai VPS to run reliable automation servers, rent a VPS from asiagb.com with RAM packages from 2–16 GB suited for automation servers, backed by 99.9% uptime SLA and Thai language support. Before deploying n8n, also verify your domain and DNS health with the free tools at dnsxray.com to ensure your webhook URLs work correctly.
Verify n8n is Working Correctly
# Check container
docker compose ps
# View logs
docker compose logs n8n -f
# Check port
ss -tlnp | grep 5678
# Test webhook endpoint
curl -X POST https://automation.yourdomain.com/webhook-test/test \
-H "Content-Type: application/json" \
-d '{"test": "ok"}'
Common Issues & Troubleshooting
Webhook not receiving requests from external services
Verify that WEBHOOK_URL is set correctly and port 443 is open. n8n uses this URL to build webhook paths:
docker exec n8n sh -c "echo \$WEBHOOK_URL"
# Should be https://automation.yourdomain.com/
# Test webhook locally
curl -v https://automation.yourdomain.com/webhook/your-webhook-id
Workflow stops running after restart
n8n requires workflows to be "Activated" and volumes must persist after restart. Verify that the volume mount is correct:
docker inspect n8n | grep -A5 Mounts
Memory keeps increasing (memory leak)
This occurs when execution history accumulates. Set execution history to auto-delete:
EXECUTIONS_DATA_PRUNE: "true"
EXECUTIONS_DATA_MAX_AGE: 168 # Keep 7 days (unit: hours)
n8n is slow when running many workflows at once
Enable queue mode for production to use separate workers:
EXECUTIONS_MODE: queue
QUEUE_BULL_REDIS_HOST: redis
# Must add Redis service as well
Frequently Asked Questions
How is n8n different from Zapier?
Zapier is a cloud service that charges per "Zaps" (number of workflows) and tasks (execution count). n8n self-hosted has no task charges—you only pay for server costs—making heavy automation much more economical. However, you must manage the server yourself.
Does n8n support code nodes?
Yes, it has Code nodes that run JavaScript or Python within workflows. This is perfect for complex logic that visual nodes can't handle, such as array manipulation, date calculations, or custom API parsing.
Can I export/import workflows?
Yes, n8n lets you export workflows as JSON and import them instantly. This is useful for sharing workflows with your team or backing up before updating n8n versions.