Webhook URL shows localhost while behind proxy

Description

I have a self hosted node that is using Caddy server and pm2 to run n8n on the localhost:5678 URL.

My environment variables intially were everything but the WEBHOOK_URL. I added WEBHOOK_URL after realizing the docs say I need it:

DOMAIN=example.com
SUBDOMAIN=n8n
N8N_USER_MANAGEMENT_DISABLED=true
N8N_BASIC_AUTH_ACTIVE=true
N8N_BASIC_AUTH_USER=username
N8N_BASIC_AUTH_PASSWORD=Secret
WEBHOOK_URL=https://n8n.example.com/

Error message?

{
    "code": 404,
    "message": "The requested webhook \"GET 561a0d14-f14a-495e-a672-241efcc4363e\" is not registered.",
    "hint": "Click the 'Execute workflow' button on the canvas, then try again. (In test mode, the webhook only works for one call after you click this button)",
    "stack": "ResponseError: The requested webhook \"GET 561a0d14-f14a-495e-a672-241efcc4363e\" is not registered.\n    at TestWebhooks.callTestWebhook (/home/ubuntu/.nvm/versions/node/v16.15.0/lib/node_modules/n8n/dist/src/TestWebhooks.js:25:23)\n    at /home/ubuntu/.nvm/versions/node/v16.15.0/lib/node_modules/n8n/dist/src/Server.js:1658:52\n    at Layer.handle [as handle_request] (/home/ubuntu/.nvm/versions/node/v16.15.0/lib/node_modules/n8n/node_modules/express/lib/router/layer.js:95:5)\n    at next (/home/ubuntu/.nvm/versions/node/v16.15.0/lib/node_modules/n8n/node_modules/express/lib/router/route.js:144:13)\n    at next (/home/ubuntu/.nvm/versions/node/v16.15.0/lib/node_modules/n8n/node_modules/express/lib/router/route.js:138:14)\n    at next (/home/ubuntu/.nvm/versions/node/v16.15.0/lib/node_modules/n8n/node_modules/express/lib/router/route.js:138:14)\n    at next (/home/ubuntu/.nvm/versions/node/v16.15.0/lib/node_modules/n8n/node_modules/express/lib/router/route.js:138:14)\n    at next (/home/ubuntu/.nvm/versions/node/v16.15.0/lib/node_modules/n8n/node_modules/express/lib/router/route.js:138:14)\n    at next (/home/ubuntu/.nvm/versions/node/v16.15.0/lib/node_modules/n8n/node_modules/express/lib/router/route.js:138:14)\n    at next (/home/ubuntu/.nvm/versions/node/v16.15.0/lib/node_modules/n8n/node_modules/express/lib/router/route.js:138:14)\n    at Route.dispatch (/home/ubuntu/.nvm/versions/node/v16.15.0/lib/node_modules/n8n/node_modules/express/lib/router/route.js:114:3)\n    at Layer.handle [as handle_request] (/home/ubuntu/.nvm/versions/node/v16.15.0/lib/node_modules/n8n/node_modules/express/lib/router/layer.js:95:5)\n    at /home/ubuntu/.nvm/versions/node/v16.15.0/lib/node_modules/n8n/node_modules/express/lib/router/index.js:284:15\n    at param (/home/ubuntu/.nvm/versions/node/v16.15.0/lib/node_modules/n8n/node_modules/express/lib/router/index.js:365:14)\n    at param (/home/ubuntu/.nvm/versions/node/v16.15.0/lib/node_modules/n8n/node_modules/express/lib/router/index.js:376:14)\n    at Function.process_params (/home/ubuntu/.nvm/versions/node/v16.15.0/lib/node_modules/n8n/node_modules/express/lib/router/index.js:421:3)\n    at next (/home/ubuntu/.nvm/versions/node/v16.15.0/lib/node_modules/n8n/node_modules/express/lib/router/index.js:280:10)\n    at /home/ubuntu/.nvm/versions/node/v16.15.0/lib/node_modules/n8n/dist/src/UserManagement/routes/index.js:126:9\n    at Layer.handle [as handle_request] (/home/ubuntu/.nvm/versions/node/v16.15.0/lib/node_modules/n8n/node_modules/express/lib/router/layer.js:95:5)\n    at trim_prefix (/home/ubuntu/.nvm/versions/node/v16.15.0/lib/node_modules/n8n/node_modules/express/lib/router/index.js:328:13)\n    at /home/ubuntu/.nvm/versions/node/v16.15.0/lib/node_modules/n8n/node_modules/express/lib/router/index.js:286:9\n    at Function.process_params (/home/ubuntu/.nvm/versions/node/v16.15.0/lib/node_modules/n8n/node_modules/express/lib/router/index.js:346:12)"
}

Workflow

n8n setup

  • n8n version: 0.175.1
  • Database you’re using: SQLite
  • Running n8n with the execution process: own
  • Running n8n via: npm

I am running n8n with pm2.io. I found that if you update the env variable that pm2 caches the other variables.

I ran this command to update the environment variables and was able to get everything to work.

pm2 restart all --update-env

Note: if you have other processes controlled by pm2 you will want to specify what to restart with pm2.

3 Likes

Glad you have resolved it. Thanks for sharing :slight_smile:

1 Like