Changing Webhook URLs in n8n (Self‑Hosted and Cloud)
Our guides are based on hands-on testing and verified sources. Each article is reviewed for accuracy and updated regularly to ensure current, reliable information.Read our editorial policy.
Webhooks are one of the core ways to trigger workflows in n8n. When you add a Webhook node to a workflow, n8n generates a unique URL that external services can call to initiate the workflow.
By default, self‑hosted n8n instances build webhook URLs using your local address (for example, http://localhost:5678/webhook/<id>). This causes issues when you need webhooks to be reachable from the internet or when you want to tidy up the endpoint path.
This tutorial explains how to change the webhook URL in n8n. It covers adjusting the path of individual Webhook nodes, setting a public base domain through environment variables, changing the default /webhook path, and regenerating a new webhook URL.
The instructions were verified against n8n v2.4.7 and v2.6.2 (the latest stable and beta versions at the time of writing) and are based on official documentation and community support discussions.
Why change the webhook URL in n8n?
- Expose webhooks externally: Many integrations (Stripe, Slack, Google, etc.) require a public URL for webhooks. Leaving localhost breaks these integrations.
- Customise endpoint names: Changing /webhook to something like /api can improve readability or security.
- Organise workflows: Using descriptive paths (e.g., /crm/new-lead) helps identify the purpose of a webhook and avoids collisions.
- Migrate domains: When moving from a development environment to production, ensure the webhook base URL reflects your new domain.
Also Check: URL Parser — Break Down Links Into Components Online
Requirements before changing URLs in n8n
Before changing webhook URLs in n8n, review these points:
| Requirement | Details |
| n8n version | Tested on self‑hosted n8n 2.4.7 (stable) and 2.6.2 (beta). n8n Cloud uses a similar interface, but you cannot change environment variables. |
| Hosting environment | Changes to environment variables require access to your server configuration (e.g., Docker Compose, .env file). If using n8n Cloud, you can only edit the webhook Path in the node UI. |
| Reverse proxy | If your instance runs behind a reverse proxy, set the WEBHOOK_URL environment variable and forward X‑Forwarded headers as documented. |
| Unique path names | When editing the path, ensure it is unique across all Webhook nodes; otherwise n8n will show a conflict. |
| Restart required | Changes to environment variables only take effect after restarting the n8n service. |
Method 1 – Change the Path in a Webhook Node
Use this method when you simply want to rename the endpoint (e.g., from webhook/<id> to api/lead-capture). It does not change the base domain or protocol.
- Open your workflow in n8n: Navigate to the workflow containing the Webhook node.
- Select the Webhook node: In the left‑hand properties panel, locate the Path field. By default, n8n generates a random UUID to avoid collisions.
- Enter a custom path: The path can include slashes and route parameters. n8n’s documentation lists valid formats such as /:variable, /path/:variable, or /path/:variable1/path/:variable2. For example, entering crm/new-lead will make the URL end with /crm/new-lead.
- Save and activate your workflow: When a workflow is unpublished, the Webhook node shows both a Test URL and a Production URL. Once published, use the production URL for external services. The new path will be visible in both test and production URLs.
- Update external systems: Replace any old webhook URLs in third‑party apps with the new URL.
Notes: Changing the path only affects that specific Webhook node. If you have multiple nodes, edit each individually. Avoid special characters and spaces in the path.
Method 2 – Set the Public Base Domain (WEBHOOK_URL)
When you self‑host n8n, the default base URL for webhooks is http://localhost:5678. External services cannot reach this address. The official docs recommend setting the WEBHOOK_URL environment variable so n8n generates URLs with your public domain.
Steps (Docker example)
- Open your environment configuration. For Docker Compose, edit your docker-compose.yml or .env file.
- Add or update the WEBHOOK_URL variable. Assign it to your public domain, including protocol and trailing slash. Example:
environment:
– WEBHOOK_URL=https://automation.example.com/ - Restart n8n. Recreate the container or restart the service. In Docker Compose you can run docker-compose up -d –force-recreate.
- Verify new URLs. Open a Webhook node; the test and production URLs should now display your domain instead of localhost. You no longer need to manually replace localhost each time.
Windows (npm) example: On Windows PowerShell, you can set the variable inline:
$env:WEBHOOK_URL=’https://automation.example.com/’; npx n8n
The community confirmed this works and pointed out that using the Unix export command doesn’t set variables in PowerShell.
Method 3 – Change the Default /webhookPath (N8N_ENDPOINT_WEBHOOK)
If you want to replace /webhook with a custom prefix (e.g., /api) for all Webhook nodes, use the N8N_ENDPOINT_WEBHOOK environment variable. This affects both test and production endpoints.
Steps
- Edit your environment configuration (docker-compose.yml, .env, or service configuration).
- Set the new endpoint path variables:
environment:
– N8N_ENDPOINT_WEBHOOK=api
– N8N_ENDPOINT_WEBHOOK_TEST=api-test # optional: change test endpoint
– N8N_ENDPOINT_WEBHOOK_WAIT=api-waiting # optional: waiting webhooks
According to the docs, the default values are webhook, webhook-test and webhook-waiting. Changing them updates the prefixes for your production, test and waiting endpoints. - Restart n8n for the changes to take effect.
- Update external services to use the new base path. For example, with N8N_ENDPOINT_WEBHOOK=api, a Webhook node with path crm/new-lead will have the URL https://automation.example.com/api/crm/new-lead.
Caution: Removing the prefix entirely (setting it to /) may not be supported in current versions. A community member noted that leaving it blank or / inserts extra slashes and is not recommended.
Check this related tool: URL Decoder — Decode Percent-Encoded URLs Online Free
Method 4 – Regenerate a Webhook URL (Clone the Workflow)
Sometimes you need to completely reset a webhook URL (for instance, if the random ID has leaked or you want to remove a legacy path). n8n allows you to clone a workflow, which generates new webhook URLs.
- In your n8n dashboard, open the workflow you want to reset.
- Choose Clone from the workflow menu: This duplicates the workflow with a new internal ID.
- Open the Webhook node in the cloned workflow: You can keep the default random path or enter a new custom path. The base domain and /webhook prefix will follow whatever environment variables you’ve set.
- Test and activate the cloned workflow. Once confirmed, deactivate or delete the original workflow to avoid receiving duplicate requests.
This method gives you a fresh webhook URL without altering environment variables or manually editing paths.
Alternative Options & Quick Tips
- Reverse proxy with TLS termination: If you run n8n behind Nginx, Traefik, Caddy, or another reverse proxy, set the WEBHOOK_URL variable and pass X‑Forwarded-For, X‑Forwarded-Host, and X‑Forwarded-Proto headers so n8n knows the original request details. Set N8N_PROXY_HOPS=1 when there is exactly one proxy in front of n8n.
- Custom test endpoints only: If you only need a different path for test webhooks, change N8N_ENDPOINT_WEBHOOK_TEST (defaults to webhook-test).
- Webhooks with route parameters: The Path field accepts dynamic segments like :id or :variable1/:variable2. Use this for multi‑tenant or tokenised endpoints.
- Authentication: For added security, require basic, header or JWT authentication in the Webhook node settings.
- n8n Cloud: You cannot modify environment variables on n8n Cloud; you can only change the path within the Webhook node. Use a reverse proxy or custom domain features provided by the cloud service if you need a custom domain.
Troubleshooting Tips
| Issue | Possible cause & fix |
| Webhook URL still shows localhost after setting WEBHOOK_URL | Ensure the environment variable is set in the correct place and restart the n8n service. In Windows PowerShell, use $env:WEBHOOK_URL=’https://example.com/’; npx n8n instead of the Unix export command. If running in Docker, add the variable under the environment section and restart the container. |
| Extra slashes in the URL (e.g., https://domain//path) | Leaving N8N_ENDPOINT_WEBHOOK blank or setting it to / can cause double slashes. Always set a valid string without a leading slash (for example, api). |
| n8n not showing the new path in the editor | After editing environment variables, the n8n editor may still show old URLs until the service is restarted. Save your workflows and restart n8n to refresh. |
| External service can’t reach webhook (timeout) | Check that your reverse proxy forwards the correct headers and that ports are open. Also confirm SSL certificates are valid. |
| Webhook conflict error | Two Webhook nodes share the same path. Use unique names for each Webhook node or update one of the paths. |
| Webhook not triggering when path changed | Ensure you update the URL in the third‑party service. Many services cache webhook endpoints, so you need to reconfigure them after you change the URL. |
Best Practices
- Plan paths before deployment: Decide on a clear naming scheme (e.g., /crm/new-lead, /billing/invoice-paid) to avoid conflicts and make endpoints self‑describing.
- Use environment variables for environments: Maintain separate .env files for development and production so your base URLs and endpoint prefixes are appropriate for each environment. Keep secrets out of your code repository.
- Restart after changes: Always restart n8n after modifying environment variables. Changes will not apply until the service restarts.
- Secure webhooks. Use HTTPS and, where possible, require authentication in the Webhook node to prevent unauthorised calls. Restrict allowed IPs if the webhook is private.
- Test both test and production URLs: n8n provides separate URLs for testing and production. Ensure your third‑party service uses the production URL for live data.
- Keep n8n up to date: Some issues with environment variables and endpoints have been resolved in newer versions; updating to the latest stable release may fix unexpected behaviour.
Conclusion
Changing the webhook URL in n8n can be as simple as editing the Path field on a Webhook node or as involved as configuring environment variables for your domain and endpoint prefixes.
To change only the endpoint path, edit the node’s Path property and publish the workflow. To change the base domain, set the WEBHOOK_URL environment variable and restart n8n. For a global change to the /webhook prefix, adjust N8N_ENDPOINT_WEBHOOK (and related variables) accordingly.
Finally, if you need a completely new webhook URL, clone the workflow to regenerate a fresh endpoint. Following the methods and best practices in this guide ensures your n8n workflows remain accessible, organized, and secure.
