DOKPLOY-GUIDE 7 min read fordnox

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

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:

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

  1. In your Dokploy project, navigate to the Domains tab
  2. Click Add Domain and enter your domain (e.g., n8n.yourdomain.com)
  3. Set the container port to 5678
  4. Enable HTTPS — Dokploy automatically provisions a Let's Encrypt SSL certificate
  5. 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

  1. In Dokploy, go to your project's Deployments tab and click Deploy
  2. Watch the build logs — you should see both n8n and n8n-db containers start
  3. Check the Logs tab for the n8n service. Look for: n8n ready on 0.0.0.0, port 5678
  4. Open https://n8n.yourdomain.com in your browser — you should see the n8n login screen
  5. Log in with your N8N_BASIC_AUTH_USER and N8N_BASIC_AUTH_PASSWORD credentials

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.

~/self-hosted-app/n8n/dokploy/get-started

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

n8n dokploy docker compose self-hosted workflow automation n8n deployment

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.