Your team pastes data between apps by hand: a form submission becomes a spreadsheet row, a spreadsheet row becomes a chat message, a chat message becomes a ticket. Each step is small; together they eat hours every week. Self-host n8n on Linux and you can automate those flows yourself, on your own server, with a visual workflow builder and over 400 integrations — without sending your data through a third-party automation cloud.

This guide installs n8n with Docker Compose on Ubuntu, puts it behind HTTPS, and builds a first workflow that turns form submissions into notifications. For another AI-era automation tool, see our LangChain AI agent guide, and for a terminal AI assistant, our ShellGPT guide.
Prerequisites – Self-Host n8n on Linux
- A Linux server (Ubuntu 24.04 works well) with Docker and Docker Compose installed and sudo access.
- A domain name pointing to the server, if you want HTTPS (recommended — n8n handles credentials and webhooks).
- Ports 80 and 443 open, or a reverse proxy you already run.
Installing n8n on Linux with Docker Compose – Self-Host n8n on Linux
Docker Compose is the simplest reliable way to run n8n: one container for the app, one volume for its data, and a database for production use. Start with a working directory and a Compose file:
mkdir -p ~/n8n && cd ~/n8n
cat > docker-compose.yml <<'EOF'
services:
n8n:
image: n8nio/n8n:latest
restart: unless-stopped
ports:
- "127.0.0.1:5678:5678"
environment:
- N8N_HOST=${N8N_HOST:-localhost}
- N8N_PORT=5678
- N8N_PROTOCOL=https
- WEBHOOK_URL=https://${N8N_HOST:-localhost}/
- GENERIC_TIMEZONE=Asia/Ho_Chi_Minh
volumes:
- n8n_data:/home/node/.n8n
volumes:
n8n_data:
EOF
docker compose up -d
docker compose ps
n8n listens on port 5678, bound to localhost in this configuration so it is not exposed directly to the internet. For a quick local test, visit http://localhost:5678 via an SSH tunnel, or point a reverse proxy at it — which is the next step for real use.
On first login, n8n asks you to create an owner account. Do this immediately and use a strong password: the owner account controls every workflow and credential on the instance.
Putting Self-Hosted n8n Behind HTTPS
Never expose n8n over plain HTTP in production — it stores API keys and OAuth tokens for your other services. The standard setup is a reverse proxy with TLS termination in front of the container. With Nginx and Certbot:
sudo apt install -y nginx certbot python3-certbot-nginx
sudo tee /etc/nginx/sites-available/n8n > /dev/null <<'EOF'
server {
listen 80;
server_name n8n.example.com;
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;
}
}
EOF
sudo ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
sudo certbot --nginx -d n8n.example.com
Then set N8N_HOST=n8n.example.com in your environment (or a .env file next to the Compose file), restart with docker compose up -d, and confirm webhooks use the public URL. Webhook URLs are generated from WEBHOOK_URL, so a wrong value here is the most common reason webhooks silently fail — they point at localhost instead of your domain.
Building Your First n8n Workflow
Workflows in n8n are node graphs: a trigger node starts the flow, and each following node transforms data or calls a service. A useful first workflow: when a webhook receives a form submission, send a message to a chat channel and append a row to a spreadsheet.
- Create a new workflow and add a Webhook trigger node. Choose POST, copy the production webhook URL, and point your form at it.
- Add an IF node to filter submissions — for example, only continue when the message field is not empty.
- Add a chat node (Slack, Telegram, or Discord) to post a notification with the submitter’s name and message.
- Add a spreadsheet node (Google Sheets or Airtable) to append the submission as a row.
- Click Execute Workflow to test with a sample submission, fix any mapping errors, then toggle the workflow Active.
Two concepts make workflows maintainable. First, expressions: {{ $json.email }} pulls a field from the incoming data, so nodes stay generic while data changes. Second, error handling: turn on “Continue on fail” only where a failed step is genuinely optional, and add an Error Trigger workflow that notifies you when any workflow fails — otherwise silent failures will eat data for days before anyone notices.
Backups, Updates, and Production Habits for n8n on Linux
n8n’s state lives in two places: the n8n_data volume (workflows, credentials, and settings in SQLite by default) and, if you configure Postgres, the database. Back up the volume regularly:
cd ~/n8n
docker compose stop n8n
docker run --rm -v n8n_n8n_data:/data -v $(pwd):/backup \
alpine tar czf /backup/n8n-backup-$(date +%F).tar.gz -C /data .
docker compose start n8n
Test restores occasionally — a backup you have never restored is a hope, not a plan. For updates, pin the image tag in production instead of tracking latest, read the release notes for breaking changes, and update on a schedule (monthly is reasonable) rather than whenever a new tag appears. For heavier use, switch from SQLite to Postgres by setting the DB_TYPE, DB_POSTGRESDB_HOST, and related variables and adding a Postgres service to the Compose file; SQLite is fine for a single user but becomes a bottleneck under concurrent executions.
Finally, protect the instance like any service holding credentials: keep it behind HTTPS, enable n8n’s basic auth or SSO if your plan supports it, restrict the admin port to your network or VPN, and rotate any credential that was ever pasted into a workflow test.
Troubleshooting Self-Hosted n8n
Webhooks return 404 or never fire. The workflow is not Active (test URLs only work while testing), or WEBHOOK_URL points at the wrong host. Activate the workflow and use the production webhook URL.
“Connection refused” from the reverse proxy. The container is not running or not listening on 5678. Check docker compose ps and docker compose logs n8n for startup errors, including port conflicts.
Workflows execute but credentials fail. Credentials are stored encrypted against the instance’s encryption key. If you recreated the volume or changed the key, existing credentials break and must be re-entered. Never delete the n8n_data volume casually.
Executions pile up or run slowly. Check concurrency and queue settings for your workload, and consider Postgres plus queue mode for production loads. SQLite with many parallel executions is the usual bottleneck.
Conclusion
Self-host n8n on Linux, and the repetitive glue work between your apps becomes a workflow you can see, test, and version — running on your own server, under your own control. Start with Docker Compose, put it behind HTTPS, build one small workflow end to end, and add backups before you automate anything critical. The full reference, including queue mode and environment variables, is in the n8n Docker hosting documentation. The first workflow you ship will pay back the setup time within a week; the tenth will make you wonder why the copying was ever manual.