How to Fix Your n8n Webhook URLs
You did it. You built the perfect automation in your self-hosted n8n. It’s a multi-step masterpiece.
You click "Execute Workflow." Your eyes are wide with anticipation.
And… nothing.
The Google login fails. The Slack message never arrives. The webhook from your other app gets lost in the void. You check the logs and see a URL that looks like localhost:5678/webhook/...
and your heart sinks.
Yeah, we've all been there.
What's an n8n Webhook URL and Why is Mine Broken?
Think of your n8n workflow as a house. The webhook URL is its mailing address.
When you run n8n on your own server (self-hosting), its default address is localhost
. This is like telling the mailman your address is just "this house." It works for things happening inside the house, but the outside world has no idea how to find you.
Your automation isn't broken; it's just telling Google to send a letter to "this house" instead of "123 Main Street, Anytown."
Why You MUST Change The Webhook URL
For many simple automations, you'll never notice. But the second you need to talk to the outside world, the localhost
address becomes a brick wall.
You absolutely need to fix this for things like:
- OAuth Logins: Letting services like Google, Microsoft, or HubSpot authenticate and redirect back to your workflow.
- Incoming Webhooks: Receiving data from apps like Stripe, GitHub, or Slack.
- Chatbots: Building interactive bots that need a stable, public-facing URL.
"Can't I Just Manually Edit the URL Each Time?"
You're smart. You're thinking, "I'll just copy the localhost
URL and paste my real domain name in there."
You could. But you'll be doing it over and over again. And you'll forget one time, and spend an hour debugging, only to realize you're the problem.
This is a one-time, permanent fix. Do it once now and save your future self a massive headache.
How to Fix It: The 1-Line Change
Ready for the big, complex solution? Here it is.
You just need to tell n8n what its public address is. You do this by adding one single environment variable to your n8n setup.
WEBHOOK_URL=https://n8n.your-awesome-domain.com
That's it. That's the whole fix.
You're telling n8n, "Hey, whenever you create a new webhook URL for the outside world, don't use localhost
. Use this real, public address instead."
Okay, But Where Do I Put That Line?
This is the only part that depends on how you set up your self-hosted n8n. You add it to the environment
section of your configuration.
For example, if you're using Docker Compose, your docker-compose.yml
file would look something like this:
services:
n8n:
image: n8nio/n8n
...
environment:
- WEBHOOK_URL=https://your-awesome-domain.com
# ... other environment variables
...
OR
Add this as your Environment Variable
WEBHOOK_URL=https://your-awesome-domain.com
After adding that line, just restart your n8n instance. Now, every new webhook URL it generates will have your real domain name, and your automations will finally work with the rest of the internet.
Don't Want The Hassle?
If you don't want to mess around with config files or you're just starting out, we've got you. Use our pre-existing n8n deployment template that has all this, and more, configured for you out of the box.