localhost:5678: n8n's default port and webhook URLs explained

localhost:5678 is the default port of n8n, the open-source workflow automation tool. The editor runs at http://localhost:5678, and Webhook nodes receive requests on the same port at /webhook/... (production) and /webhook-test/... (test). The editor working locally is the easy part; getting Stripe, GitHub or a form provider to reach those webhook URLs is where most self-hosted n8n setups get stuck.

Start n8n on 5678

npx n8n
# or Docker
docker run -it --rm --name n8n -p 5678:5678 \
  -v n8n_data:/home/node/.n8n docker.n8n.io/n8nio/n8n

Then open http://localhost:5678 and create the owner account.

Fix "localhost:5678 refused to connect"

  1. Wait for Editor is now accessible via: http://localhost:5678. First start runs database migrations and can take a while.
  2. Docker port mapping. docker ps must show 0.0.0.0:5678->5678/tcp. With Docker Compose, check the ports: entry for the n8n service.
  3. Secure cookie error. Opening n8n over plain HTTP on anything other than localhost (a LAN IP, say) shows a warning about secure cookies. Use HTTPS, or for local testing only set N8N_SECURE_COOKIE=false.
  4. Wrong port. If you set N8N_PORT, the editor moved with it.

Free or change port 5678

# macOS / Linux
lsof -i :5678
kill -9 $(lsof -ti :5678)
# Windows
netstat -ano | findstr :5678
taskkill /PID <pid> /F

Change the port with N8N_PORT=5679 npx n8n, or in Docker keep the container port and change the host side: -p 5679:5678.

n8n test URL vs production URL

Every Webhook node has two URLs, and mixing them up is the most common n8n webhook problem:

Test URLProduction URL
Path/webhook-test/<path>/webhook/<path>
Works whenYou clicked Listen for test eventThe workflow is active
Requests acceptedOne, then it stops listeningEvery request
Shows in editorYes, liveIn Executions

A request to the wrong one gets a 404 "The requested webhook is not registered". Use the test URL while building, then switch the provider to the production URL and activate the workflow.

Make n8n webhooks work behind a tunnel or proxy

n8n builds the webhook URL it shows (and registers with providers, for trigger nodes like the GitHub or Stripe triggers) from its own host. Without help, that's http://localhost:5678/webhook/..., which no provider can reach. When n8n sits behind a reverse proxy or a tunnel, tell it the public address:

WEBHOOK_URL=https://n8n.example.com/

Restart n8n and the Webhook nodes show the public URL. If a reverse proxy terminates TLS, also set N8N_PROXY_HOPS=1 so n8n trusts the forwarded headers. n8n start --tunnel exists, but n8n describes it as for local development and testing only.

You can then put the whole instance on a public URL:

relay connect --name my-n8n http://localhost:5678

and set WEBHOOK_URL to the HTTPS URL it prints. Reusing the same --name keeps that URL stable, so providers don't need re-registering after a restart. This also exposes the n8n editor, so keep owner login enabled with a strong password.

Receive webhooks without exposing n8n

If you only need webhooks in, not remote access to the editor, you don't have to expose port 5678 at all. The Webhook Relay Trigger node gives each workflow a stable public URL; n8n opens an outbound WebSocket and events flow in over it. No WEBHOOK_URL, no reverse proxy and no inbound port. The same works for email with the n8n Email Trigger, and for chat apps in the WhatsApp Cloud API tutorial.

Frequently asked questions

What is localhost:5678?

localhost:5678 is the default port of n8n, the workflow automation tool. Starting n8n with npx n8n or the Docker image serves the editor at http://localhost:5678, and webhook nodes receive requests on the same port under /webhook/ and /webhook-test/.

What is the difference between the n8n test URL and production URL?

The test URL contains /webhook-test/ and only accepts a request while you have clicked Listen for test event in the editor, then it stops. The production URL contains /webhook/ and only works while the workflow is active. Calling the wrong one returns a 404 saying the webhook is not registered.

Why do my n8n webhook URLs say localhost?

n8n builds webhook URLs from its own host and port unless you tell it the public address. Set the WEBHOOK_URL environment variable to your public HTTPS URL, for example https://n8n.example.com/, and restart n8n so the webhook nodes show and register the right URL.

How do I change the n8n port?

Set the N8N_PORT environment variable, for example N8N_PORT=5679, and restart n8n. With Docker you can instead keep n8n on 5678 inside the container and publish a different host port with -p 5679:5678.