🐞 You've deployed n8n on a VPS, created a webhook workflow, but the URL shows http://localhost:5678/webhook/... instead of your public domain. When you try to call it, you get a 404 or connection refused error. This is one of the most common n8n errors after self‑hosting.
In this guide, I'll show you exactly how to fix it in 5 minutes – no Docker wizardry required.
Why Does This Error Happen?
When you run n8n locally during development, it automatically uses localhost. After moving to a VPS, n8n doesn't magically know your domain. It keeps using the old localhost address for webhook URLs unless you tell it otherwise.
N8N_HOST and N8N_PROTOCOL. If these aren't set, n8n falls back to localhost.
Fix #1: Set Environment Variables (Most Important)
If you're running n8n with Docker, add these environment variables to your docker-compose.yml or run command:
version: '3'
services:
n8n:
image: n8nio/n8n
restart: always
environment:
- N8N_HOST=your-domain.com
- N8N_PROTOCOL=https
- N8N_PORT=5678
ports:
- "5678:5678"
volumes:
- n8n_data:/home/node/.n8n
volumes:
n8n_data:If you're using systemd (without Docker), edit the service file or add to .env:
N8N_HOST=your-domain.com N8N_PROTOCOL=https N8N_PORT=5678 WEBHOOK_URL=https://your-domain.com/
After changing, restart n8n: docker restart n8n or sudo systemctl restart n8n.
Fix #2: Configure SSL (If You're Using HTTPS)
If your domain has HTTPS (which it should), you also need to set N8N_PROTOCOL=https. Without this, webhook URLs will still use http:// and your browser may block them.
N8N_PROTOCOL=https and N8N_HOST=your-domain.com.
Fix #3: Activate Your Workflow
Even after fixing the URL, n8n won't listen for webhooks unless the workflow is Active (the toggle switch at the top right). A common mistake: you've set everything up but forgot to turn the workflow on.
Testing Your Webhook
Use a free tool like webhook.site or Postman to send a test POST request to your new webhook URL. You should see the execution in n8n.
curl -X POST https://your-domain.com/webhook/your-path \
-H "Content-Type: application/json" \
-d '{"test": "Hello from TriggerWorkflow"}'Frequently Asked Questions
docker restart n8n or restart your systemd service.WEBHOOK_URL variable. Remove it and rely on N8N_HOST + N8N_PROTOCOL instead. Also ensure your workflow is active.
