When deploying n8n on localhost and using a Cloudflare tunnel, the webhook node still gets assigned the local address instead of the tunnel URL. This causes issues when external services try to access the webhook.
I think n8n should have an option to manually assign a webhook address, so we can directly set the tunnel URL as the webhook.
Hey @foginevury hope all is well. Welcome to the community.
Have you set the WEBHOOK_URL env variable? Have you restarted the instance after that?
No, I haven’t done that yet. Could you please guide me on how to set the WEBHOOK_URL environment variable and restart the instance properly?
You would usually set this under environments in your docker compose or you pass this environment variable with docker run command.
See the following guides:
n8n creates the webhook URL by combining N8N_PROTOCOL, N8N_HOST and N8N_PORT. If n8n runs behind a reverse proxy, that won't work. That's because n8n runs internally on port 5678 but the reverse proxy exposes it to the web on port 443. | Customize...
As to rebooting - that solely depends on how you are running your instance. Tell us more about that.
I’m not using Docker. I installed n8n with npm install -g n8n.
In this case, how can I set the tunnel link as the webhook URL?
foginevury:
WEBHOOK_URL
You can either prepend the variable before starting n8n
WEBHOOK_URL=https://example.com/ n8n
or you can export your variable and then start n8n
export WEBHOOK_URL=https://example.com/
n8n
I think it should also be possible to store env vars to a file .env in the place where you run n8n from
.env
WEBHOOK_URL=https://example.com/
and then run n8n
n8n
Yes, it worked!
Here’s the permanent solution for setting the webhook URL so n8n always uses the tunnel link instead of localhost:
Windows:
Go to System Properties > Environment Variables
Add a new system variable:
Name: WEBHOOK_URL
Value: https://your-tunnel-link.domain/
Save and restart your terminal/PC
Linux / Mac:
If my answer helped you to solve your problem, kindly mark my answer as Solution.
Thanks.
Cheers.