Menu
User

DropVPS Team

Writer: Cooper Reagan

how to install n8n on windows server 2025

how to install n8n on windows server 2025

Publication Date

10/12/2025

Category

Articles

Reading Time

5 Min

Table of Contents

Running n8n on Windows Server 2025 is straightforward and stable with WSL 2 and Docker. The stack below uses PostgreSQL for production-ready persistence, optional HTTPS via Caddy, and autostart on reboot. The process fits semi-technical admins who prefer clean, repeatable deployments and easy upgrades.

Prepare Windows Server 2025

Apply latest updates, sign in as an Administrator, and confirm outbound internet and inbound firewall rules can be adjusted. Have a domain ready if you want automatic HTTPS.

Enable WSL 2 and install Ubuntu

Enable the Linux subsystem and virtualization features, then install Ubuntu. This provides a lightweight Linux environment for Docker and n8n.

dism /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
wsl --install -d Ubuntu

When prompted, create a Linux username and password.

Enable systemd inside WSL

systemd ensures Docker and your containers auto-start inside WSL.

wsl -d Ubuntu
sudo sh -c 'printf "[boot]\nsystemd=true\n" >/etc/wsl.conf'
exit
wsl --shutdown
wsl -d Ubuntu

Install Docker Engine in Ubuntu (WSL)

Install Docker CE and the Compose plugin. Add your user to the docker group.

sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg lsb-release
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/ubuntu $(. /etc/os-release; echo $VERSION_CODENAME) stable" \
| sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo usermod -aG docker $USER
newgrp docker
sudo systemctl enable --now docker
docker version

Create n8n and PostgreSQL stack

Create a working directory and persistent volumes, then prepare environment variables and a Compose file for n8n and Postgres.

mkdir -p ~/n8n/data ~/n8n/db
cd ~/n8n
openssl rand -hex 32 > .n8n_key

Create a .env file. Replace values for domain, strong passwords, and email.

# .env
N8N_HOST=your-domain.example
N8N_PROTOCOL=http
N8N_BASIC_AUTH_ACTIVE=true
N8N_BASIC_AUTH_USER=admin
N8N_BASIC_AUTH_PASSWORD=SuperStrong_Passw0rd
N8N_ENCRYPTION_KEY=$(cat .n8n_key)
WEBHOOK_URL=http://your-domain.example/
GENERIC_TIMEZONE=UTC

DB_POSTGRESDB_DATABASE=n8n
DB_POSTGRESDB_USER=n8n
DB_POSTGRESDB_PASSWORD=AnotherStrong_Password

Create docker-compose.yml.

# docker-compose.yml
version: "3.8"
services:
  db:
    image: postgres:15-alpine
    environment:
      - POSTGRES_USER=${DB_POSTGRESDB_USER}
      - POSTGRES_PASSWORD=${DB_POSTGRESDB_PASSWORD}
      - POSTGRES_DB=${DB_POSTGRESDB_DATABASE}
    volumes:
      - ./db:/var/lib/postgresql/data
    restart: unless-stopped

  n8n:
    image: n8nio/n8n:latest
    ports:
      - "5678:5678"
    environment:
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=db
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_DATABASE=${DB_POSTGRESDB_DATABASE}
      - DB_POSTGRESDB_USER=${DB_POSTGRESDB_USER}
      - DB_POSTGRESDB_PASSWORD=${DB_POSTGRESDB_PASSWORD}
      - N8N_BASIC_AUTH_ACTIVE=${N8N_BASIC_AUTH_ACTIVE}
      - N8N_BASIC_AUTH_USER=${N8N_BASIC_AUTH_USER}
      - N8N_BASIC_AUTH_PASSWORD=${N8N_BASIC_AUTH_PASSWORD}
      - N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}
      - N8N_HOST=${N8N_HOST}
      - N8N_PORT=5678
      - N8N_PROTOCOL=${N8N_PROTOCOL}
      - WEBHOOK_URL=${WEBHOOK_URL}
      - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
    volumes:
      - ./data:/home/node/.n8n
    depends_on:
      - db
    restart: unless-stopped

Start n8n with Docker Compose

Pull images and start the stack in the background.

cd ~/n8n
docker compose pull
docker compose up -d
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
NAMES   STATUS          PORTS
n8n     Up 30 seconds   0.0.0.0:5678->5678/tcp
db      Up 31 seconds   5432/tcp

Open Windows Firewall and test

Expose port 5678 temporarily, then verify access from a browser at http://SERVER-IP:5678.

powershell -Command "New-NetFirewallRule -DisplayName 'n8n 5678' -Direction Inbound -Protocol TCP -LocalPort 5678 -Action Allow"

Log in with the basic auth credentials you set, then finish n8n’s first-run setup. Move to HTTPS before going public.

Optional: HTTPS with Caddy reverse proxy

Use Caddy to get automatic Let’s Encrypt certificates and a clean URL.

cd ~/n8n
mkdir caddy
cat > caddy/Caddyfile <<'EOF'
your-domain.example {
  encode zstd gzip
  reverse_proxy n8n:5678
  tls [email protected]
}
EOF

Add Caddy to docker-compose.yml.

# append to docker-compose.yml
  caddy:
    image: caddy:2
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./caddy/Caddyfile:/etc/caddy/Caddyfile:ro
      - ./caddy/data:/data
    depends_on:
      - n8n
    restart: unless-stopped

Update n8n protocol and webhook URL for HTTPS, then restart.

sed -i 's/N8N_PROTOCOL=http/N8N_PROTOCOL=https/' .env
sed -i 's#WEBHOOK_URL=.*#WEBHOOK_URL=https://your-domain.example/#' .env
docker compose up -d

Autostart after server reboot

Ensure WSL starts at boot so systemd launches Docker and your containers.

schtasks /Create /TN "WSL-Autostart" /SC ONSTART /RL HIGHEST /TR "wsl -d Ubuntu -e /bin/true" /F

Backup and update n8n safely

Back up volumes before upgrades, then pull the latest image and restart the service.

cd ~/n8n
tar -czf n8n-backup-$(date +%F).tar.gz data db
docker compose pull n8n
docker compose up -d --no-deps n8n
docker logs -f n8n

Optional: Native Windows install (Node.js + service)

For small labs without Docker, run n8n directly on Windows. Use PostgreSQL for durability.

winget install OpenJS.NodeJS.LTS
npm install --global n8n
setx N8N_BASIC_AUTH_ACTIVE true /M
setx N8N_BASIC_AUTH_USER admin /M
setx N8N_BASIC_AUTH_PASSWORD SuperStrong_Passw0rd /M
setx N8N_ENCRYPTION_KEY 32CHARLONG_RANDOM_VALUE /M
n8n start

To run as a Windows service, install NSSM, then wrap n8n’s start command as a service and set Automatic startup. For more how-tos, guidance, and to buy servers with expert support, visit dropvps.com. For more guides, visit dropvps.com

Windows VPS
U
Loading...

Related Posts