WEBHOOK_URL with pm2 setup

I have installed n8n locally with the global flag:
npm install n8n -g

I start it easily with n8n start

Now I am trying to add it to pm2 to ensure it restarts on crash or restart.
I also try to setup my custom domain webhook url.

I run:
pm2 start "n8n start --tunnel" --name n8n --env WEBHOOK_URL=https://hook.mydomain.com

It starts properly however when setting the tunnel it doesn’t use my custom domain:

0|n8n | Waiting for tunnel …
0|n8n | Tunnel URL: https://abc-abc-12.hooks.n8n.cloud/

My custom domain is setup to redirect to that machine.
There is an nginx reverse proxy in front that proxy pass https traffic to n8n on http://localhost:5678

What am I missing to set up the proper webhook url?

Information on your n8n setup

  • **n8n version:1.85.0
  • **Database (default: SQLite):SQLite
  • **Running n8n via (Docker, npm, n8n cloud, desktop app): npm
  • **Operating system:ubuntu 20.04

According to the documentation, it should be

WEBHOOK_URL=https://hook.mydomain.com pm2 start "n8n start --tunnel" --name n8n

Same thing, it does not use my custom domain

I’ve just tried with an ecosystem file and same issue:

pm2 start ecosystem.config.js

module.exports = {
  apps: [{
    name: "n8n",
    script: "n8n  start --tunnel",
    env: {
         WEBHOOK_URL: "https://hook.mydomain.com"
    }
  }]
}

Found the issue.
When you use the --tunnel flag, it uses n8n server to generate a webhook url and overrides your local variable.
Do not use --tunnel if you want to use your own custom domain

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.