N8n Desktop custom Webhook url ngrok

Hello,
How is it possible to custom the url of the webhook on the Desktop app ?
To make it usable with ngrok for example.

Merci

Hey @tiger360,

I think the desktop app uses local tunnel which is an ngrok style service to ceate the webhook URLs and expose your service to the outside world.

Was there any specific reason why you would want to use ngrok over what the desktop app already provides?

1 Like

thank you for the answer
actually I wanted to use ngrok to make sure that the webhook url is not changing.
because if I close it and rerun it, I’ll get another random webhook url

That sounds like a legit case although maybe something that could be fixed within n8n so you would always have the same URL, I am sure there is probably already an internal feature request for this to happen.

I have had a quick play and you can set the the WEBHOOK_TUNNEL_URL environment variable in the .n8n/n8n-desktop.env file that can be found in your users home directory that will then tell the n8n desktop app what URL to use / display for the webhook options, Set this to your ngrok URL and things seem to be all good.

The steps below are what I did to get it working but I only did a bit of testing so you may have different results.

Run ngrok and tell it to use the n8n web server which is listening on port 5679 (you can see this in the n8n-desktop.env file).

ngrok http 5679

Once that shows it is running grab the URL for the HTTPS connection and update the config file, You will need to add in the environment variable option.

N8N_DEPLOYMENT_TYPE='desktop_mac'
EXECUTIONS_PROCESS='main'
EXECUTIONS_DATA_SAVE_ON_PROGRESS=true
EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONS=true
N8N_BASIC_AUTH_ACTIVE=true
N8N_BASIC_AUTH_USER='removed-my-user'
N8N_BASIC_AUTH_PASSWORD='removed-my-pass'
N8N_PORT=5679
WEBHOOK_TUNNEL_URL='https://some-long-id.ngrok.io'

Now when you run n8n it will be using your ngrok URL and you can work on the fun stuff and get those tasks automated :+1:

6 Likes

Thank you very much,
it’s working well with ngrok ::
In case I’d like to use localhost, why it’s not working the same way ?
I’ve tried with the ip address or 127.0.0.1 but it cannot reach n8n .
I tried also to change the hosts file to redirect localhots.com for example to 127.0.0.1

WEBHOOK_TUNNEL_URL='http://localhost'

Hey @tiger360,

What happens if you set it to http://localhost:5679 or have it as http://localhost then visiting the link add the 5679 port to the request? In my testing here in a Windows VM that seems to work.

1 Like

Hey @Jon
Sorry for the delay,
Thank you very much, it’s working :grinning:.
Actually, I don’t have to change the webhook in case I just want to trigger it locally
so like you said :
http://localhost:5679/webhook/252c5248-ea0b-43ab-b99b-59895658 is working perfectly :wink:

1 Like