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.
Understanding the n8n_webhook_url Environment Variable
Most users don’t realize that fixing webhook issues only requires setting an n8n_webhook_url environment variable n8n. This variable defines your public address and ensures external apps can reach your workflows successfully.
"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 Change Webhook URL in n8n
Instead of editing URLs manually, the recommended way to n8n change webhook url is via a permanent configuration in your environment settings. This avoids accidental mistakes and future debugging issues.
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.
Using n8n Environment Variables correctly
You can set the n8n environment variables n8n_webhook_url once and let n8n automatically generate correct URLs every time.
WEBHOOK_URL=https://n8n.your-awesome-domain.com
This n8n_webhook_url setting instantly tells n8n to stop using localhost and use your actual public domain instead.
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
...
Where does webhook_url belong?
It must be declared under the webhook_url environment section in your configuration. Without this, n8n falls back to localhost and external apps fail to reach your workflows.
OR
n8n webhook_url and why it matters
Setting an n8n webhook_url prevents endless redirect issues and authentication failures when using OAuth services.
Add this as your Environment Variable
WEBHOOK_URL=https://your-awesome-domain.com
Some users search for n8n webhook url environment variable webhook_url, but the correct format must follow n8n’s configuration style or it will not work.
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. To take your workflows further, learn how to combine and summarize data effectively in our n8n Merge vs. Aggregate Node: A Complete Guide.
Solving webhook n8n localhost Issues
One of the most common errors is webhook n8n localhost being displayed in OAuth flows. This means your environment variable was not correctly set.
Common Mistakes When Setting n8n Webhook URL
Many users run into issues when they see n8n webhook localhost inside their execution logs. This happens when the public URL was never set correctly. To solve this, make sure you assign the correct n8n webhook_url environment variable name in your configuration.
When unsure, a simple way to n8n set url is to edit your Docker or server environment file and restart the instance. Once done, n8n will automatically generate working webhook URLs.
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. For a broader look at how automation can accelerate your business workflows, check out AI Automation: The Secret Weapon for B2B Growth.
Get the Perfect n8n Setup in 5 Minutes →
What is the n8n default url?
By default, n8n uses n8n default url as localhost:5678, which is why external APIs fail unless configuration is updated.
How to Change n8n Webhook URL – Final Guide
If you're wondering how to change n8n webhook url, the answer is simple: set a permanent environment variable and restart your instance. No code changes needed.
