Deploy n8n with Dokploy: Docker Compose Setup Guide
Step-by-step guide to deploying n8n workflow automation on your VPS using Dokploy and Docker Compose. Includes persistent storage, SSL, and production configuration.
Deploy n8n with Dokploy
Dokploy is an open-source server management platform that simplifies deploying Docker Compose applications on your VPS. It handles reverse proxy configuration, SSL certificates, and deployment management — making it the ideal tool for getting n8n running in production with minimal effort.
This guide walks you through deploying n8n with PostgreSQL as the database backend, persistent file storage, and automatic HTTPS.
Prerequisites
- A VPS with at least 1 vCPU, 2 GB RAM, and 10 GB storage
- Dokploy installed and running on your server (installation docs)
- A domain name (e.g.,
n8n.yourdomain.com) with DNS A record pointing to your server's IP
Docker Compose Configuration
Create a new Compose project in Dokploy and paste the following configuration:
version: "3.8"
services:
n8n:
image: n8nio/n8n:latest
restart: unless-stopped
ports:
- "5678:5678"
environment:
# Database configuration
- DB_TYPE=postgresdb
- DB_POSTGRESDB_HOST=n8n-db
- DB_POSTGRESDB_PORT=5432
- DB_POSTGRESDB_DATABASE=n8n
- DB_POSTGRESDB_USER=n8n
- DB_POSTGRESDB_PASSWORD=${N8N_DB_PASSWORD}
# General settings
- N8N_HOST=${N8N_DOMAIN}
- N8N_PORT=5678
- N8N_PROTOCOL=https
- WEBHOOK_URL=https://${N8N_DOMAIN}/
# Security
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER=${N8N_BASIC_AUTH_USER}
- N8N_BASIC_AUTH_PASSWORD=${N8N_BASIC_AUTH_PASSWORD}
# Timezone
- GENERIC_TIMEZONE=${TZ:-UTC}
volumes:
- ../files/n8n-data:/home/node/.n8n
depends_on:
n8n-db:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "wget -qO- http://localhost:5678/healthz || exit 1"]
interval: 30s
timeout: 10s
retries: 3
n8n-db:
image: postgres:16-alpine
restart: unless-stopped
environment:
- POSTGRES_DB=n8n
- POSTGRES_USER=n8n
- POSTGRES_PASSWORD=${N8N_DB_PASSWORD}
volumes:
- ../files/n8n-db-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U n8n"]
interval: 10s
timeout: 5s
retries: 5
Environment Variables
Set these in Dokploy's Environment tab for your compose project:
| Variable | Purpose | Example |
|---|---|---|
N8N_DOMAIN |
Your n8n domain name | n8n.yourdomain.com |
N8N_DB_PASSWORD |
PostgreSQL database password | a-strong-random-password |
N8N_BASIC_AUTH_USER |
Admin username for n8n | admin |
N8N_BASIC_AUTH_PASSWORD |
Admin password for n8n | another-strong-password |
TZ |
Server timezone | America/New_York |
In Dokploy, environment variables are set via the Environment editor in the project settings. Do not create a .env file manually — Dokploy manages this for you.
Volumes & Data Persistence
This setup uses Dokploy's ../files convention for bind-mounted volumes:
../files/n8n-data— n8n's configuration, encryption keys, and custom nodes../files/n8n-db-data— PostgreSQL database files
The ../files path is relative to the compose file inside Dokploy's project directory. This convention ensures your data persists across redeployments. Avoid using absolute paths (e.g., /opt/n8n-data) because Dokploy may clean them during redeployment.
If you need S3 backup support, consider using named Docker volumes instead. Named volumes can be backed up with Dokploy's built-in backup features. Add them under a top-level volumes: key in your compose file.
Domain & SSL Setup
- In your Dokploy project, navigate to the Domains tab
- Click Add Domain and enter your domain (e.g.,
n8n.yourdomain.com) - Set the container port to
5678 - Enable HTTPS — Dokploy automatically provisions a Let's Encrypt SSL certificate
- Save and wait for the certificate to be issued (usually under a minute)
Dokploy's built-in Traefik reverse proxy handles TLS termination and routes traffic to your n8n container.
Verifying the Deployment
- In Dokploy, go to your project's Deployments tab and click Deploy
- Watch the build logs — you should see both
n8nandn8n-dbcontainers start - Check the Logs tab for the
n8nservice. Look for:n8n ready on 0.0.0.0, port 5678 - Open
https://n8n.yourdomain.comin your browser — you should see the n8n login screen - Log in with your
N8N_BASIC_AUTH_USERandN8N_BASIC_AUTH_PASSWORDcredentials
Troubleshooting
n8n container keeps restarting
Check the logs for database connection errors. Ensure N8N_DB_PASSWORD matches between the n8n and PostgreSQL services. The n8n container depends on the database health check — if PostgreSQL hasn't finished initializing, n8n will wait and retry.
Webhooks not working
Verify that WEBHOOK_URL is set to your full domain with https://. Webhook URLs must be publicly accessible. Check that your domain DNS is resolving correctly and that Dokploy's Traefik proxy is forwarding traffic to port 5678.
Permission errors on volumes
The n8n Docker image runs as user node (UID 1000). If the ../files/n8n-data directory was created with different ownership, run chown -R 1000:1000 on the directory from your server's shell.
SSL certificate not issuing Ensure your domain's DNS A record points to your server's IP and has propagated. Dokploy uses Let's Encrypt HTTP-01 challenges, so port 80 must be accessible. Check Traefik logs in Dokploy for certificate-related errors.
Learn more about n8n in our complete overview.
Need a VPS? Hostinger VPS starts at $4.99/mo — perfect for running n8n.
For more on Docker Compose deployments in Dokploy, see the Dokploy Docker Compose documentation.
App data sourced from selfh.st open-source directory.
Ready to get started?
Get the best VPS hosting deal today. Hostinger offers 4GB RAM VPS starting at just $4.99/mo.
Get Hostinger VPS — $4.99/mo// up to 75% off + free domain included
// related topics
fordnox
Expert VPS reviews and hosting guides. We test every provider we recommend.
// last updated: February 12, 2026. Disclosure: This article may contain affiliate links.