Test Webhooks for my Self-hosted railway Deployment with Webhook processor + workers do not work
I am deploying this template on railway:
It has 5 services:
PostgreSQL
Redis
Primary n8n
Worker n8n
Webhook processor N8n
I am advised to have these set in my primary n8n
EXECUTIONS_MODE=queue
N8N_DISABLE_PRODUCTION_MAIN_PROCESS=true
WEBHOOK_URL=https://webhook-processor-production-[redacted].up.railway.app/
(https://webhook-processor-production-[redacted].up.railway.app/ is my public domain for my webhook processor instance)
Which allows for a good ui and editor experience.
However the problem i have is that test webhooks respond with:
However production webhooks work when the workflow is active.
This result is reversed when i change:
WEBHOOK_URL=https://primary-production-[redacted].up.railway.app/webhook-test/9210ae3a-b25a-4273-8127-2712f03577e9
i.e test webhooks work, production ones do not.
Basically i do not know how to also open up the test webhooks endpoint while also having production endpoints go through the load balancing that the webhook processor does for me.
We do not support Railway so some of this is going to come down to your knowledge of that platfrom.
Typically when using webhook workers a loadbalancer would be used to make sure that /webhook-test/* goes to the main instance of n8n and /webhook/* routes to the pool of webhook workers. Have you configured your loadbalancer for this or are you sending everything to the webhook worker?
and deploying it, and uses this start command:
n8n webhook
So from what i understand. It must be using whatever default configuration is set from the n8n docker container, and it’s logic is all determined by the defaults and the env vars i put in.
We don’t include a load balancer (which is a requirement for webhook workers in our docs) so I suspect at some point you must be telling n8n which url to use. Does Railway generate different URLs for the main instance and the webhook worker?
Ah, I thought the webhook processor was the load balancer.
So railway generates a public domain for the Webhook Processor and the Primary instances. The Webhook worker however is not public facing and has a private internal domain - which I am not exactly sure how the other instances interact with it as that private domain is not passed as an env var to the other two.
So apparently railway does have inbuilt load balancing as I can increase the replica’s of the Webhook processor instance and the Worker instance. And they mention it here:
So in your case the webhook worker needs to be public, You would set the WEBHOOK_URL env option to your webhook worker (if you only have one if you have multiple it would point to your load balancer).
Then you would need to set N8N_EDITOR_BASE_URL to be the URL for the main instance. That should solve the issue.
Okay I think I am a bit confused, i just want to clarify.
Current Setup
Primary
start command: n8n start
public domain: true
WebhookURL: set to public webhook processor
Webhook Processor
start command: n8n webhook
publicDomain: true
Worker
start command: n8n worker
public domain: false
When you say “Webhook Worker” - do you mean the Worker instance with start command “n8n worker”?
Changes you suggest
Primary
start command: n8n start
public domain: true
WebhookURL: change this to Worker public domain
N8N_EDITOR_BASE_URL: Primary instance public domain (itself)
Webhook Processor
start command: n8n webhook
publicDomain: true
Worker
start command: n8n worker
public domain: change to true
Here are my questions:
Is this correct?
What does the webhook processor actually do then?
What doesn’t make sense here is that the Webhook Processor instance doesn’t seem to be doing anything now. So i will also try to see if this combination works with just the added n8n_editor_base_url set to the primary instance.
Okay so as it stands I have actually done the following and it worked:
Primary
start command: n8n start
public domain: true
WebhookURL: Kept this pointing to public domain of Webhook Processor
N8N_EDITOR_BASE_URL: Primary instance public domain (itself) - this is what was missing!
Webhook Processor
this stayed the same
start command: n8n webhook
publicDomain: true
Worker
this stayed the same, i did not make it public
start command: n8n worker
public domain: kept it to false
Conclusion
So in the end, what I was missing was the N8N_EDITOR_BASE_URL was not set on my primary instance.
Follow up Questions
What i still would like to understand is:
What does the Webhook Processor instance do (the “n8n webhook” start command)
which instances should i have replica’s for and have a load balancer on top of? from what i understand, the Worker processes the jobs, and the webhook processor processes the incoming request, so i would need a load balancer for both?
The webhook processor handles webhook requests, this would be what outside users or systems interact with for inbound data items.
This is up to you, You can’t have multiple main instances without an enterprise license but you can have as many workers and webhook processors as you want. The only thing you would need to load balance is the webhook processors, This is covered in the documentation here: Configuring queue mode | n8n Docs
I solved the problem using Self-hosted Railway Deployment. I’ll share how it worked for me, which might help you. Directly from the Railway panel, during the N8N installation, choose the worker, select the three dots, and apply a redeploy.