Use webhooks locally in n8n
Table of Contents
Introduction
This tutorial will guide you through the process of using webhooks locally in n8n by running it in tunnel mode. This feature allows you to create a publicly accessible webhook URL, facilitating testing and integration with external services. By following these steps, you'll be able to set up n8n quickly and efficiently.
Step 1: Starting n8n in Tunnel Mode
To enable tunnel mode in n8n, you need to run it with the --tunnel option. This option can be added based on the method you use to run n8n, either via npm or Docker.
Using npm
- Open your terminal.
- Run the following command:
n8n start --tunnel
Using Docker
- Open your terminal.
- Use the following command, ensuring to include the
--tunneloption:docker run -it --rm \ --name n8n \ -p 5678:5678 \ -v n8n_data:/home/node/.n8n \ docker.n8n.io/n8nio/n8n \ start --tunnel
Using Docker Compose
- Open your
docker-compose.ymlfile. - Add the following line under the service definition:
command: ["start", "--tunnel"]
Step 2: Accessing Your Webhook URL
Once n8n is running in tunnel mode, the webhooks you create will automatically use the new tunnel URL. This new URL can be accessed externally, allowing you to test integrations with various services.
Important Notes
- The webhook URL remains the same even if you restart the n8n instance, which is convenient for ongoing testing.
- When you exit tunnel mode, your webhooks will revert to the localhost URL.
Conclusion
By following these steps, you can efficiently set up n8n in tunnel mode and test your webhooks locally. This setup provides a seamless way to work with external integrations and ensures that your webhook URLs remain consistent across sessions. For further exploration, consider integrating n8n with various applications to maximize its capabilities.