Webhook error 404

Hello everyone,

I’m experience a strange problem with my n8n installation.

I’m trying to execute a webhook I’ve created but the api is returning me a 404 with a html body.

<html lang="en">

<head>

<meta charset="utf-8">

<title>Error</title>

</head>

<body>

<pre>Cannot POST /webhook/abc123</pre>

</body>

</html>

It does not matter the webhook name or the method, I get the same error.

What makes it stranger is that if I put the webhook in test mode it works without any problem with this url : webhook-test/abc123

At first I thought that it might be a domain name issue but I get the same error just by calling the webhook manually with curl to localhost:5678

My n8n version is the last one and my .env is:

Hey @massimo!

Are you using the Production Webhook URL? If yes, is your workflow active? Also, if you’re making a GET request make sure to select GET from the HTTP Method dropdown list in the Webhook node. I would suggest you go through the Webhook node documentation. Let me know if you still face any issues :slight_smile:

Thank you for your quick response @harshil1712.

The workflow is active and testing with a GET request in production still happens the same.

Hey @massimo! Could it be that the request is POST and the webhook node has GET method set? (or vice-versa) :face_with_monocle:

Hello,

After several updates, currently I have the latest of all, I still have the same problem. The webhook in the test environment responds perfectly, but in the production environment I get a 404 error…

I’ve tried with an old version of n8n (which I’ve had installed for months without updating) and I don’t have this problem. On the same server, I tried installing the latest version and the same thing.

Please, I need your help. Any solution?

Thank you very much in advance,
Massimo

Hey @massimo!

Are your workflows active? Can you try deleting the Webhook node and adding a new one?

Hey @harshil1712,

Thank you for your reply. The workflow is active, if it had not been the POST to the test would not have been executed either, and yes, I have also tried in another workflow totally new and the same problem.

For the Test URL you have to run the workflow manually either by clicking on the Execute Node button or the Execute Workflow button.

However, when your workflow is active (turn on the Active toggle on the top right of the Editor UI), you don’t have to execute the workflow manually. Here’s the playlist that might help you better understand this: https://www.youtube.com/playlist?list=PLlET0GsrLUL5niZQDjW56b_AxpvnEZyps

That is not the problem. I know that I have to manually start the workflow to start the webhook and it responds perfectly when it is a “test”. The problem is, when I send the request to the production URL it doesn’t work, and this didn’t happen in previous versions of n8n. Any solution? Thanks in advance.

Hey @massimo!

I am sure why you’re facing this issue. If it worked in the previous version, it should work for the latest version as well. Can you check if the production Webhook is getting registered in the external service you’re using?

Can you also share how you’re using n8n? Are you self-hosting n8n? If yes, how did you deploy it? Maybe you missed a step while deploying n8n, which is causing this error.

I’m using the webhook node and I’m having the same issue… my test webhooks are working fine, but the production ones give me the error above. If I’m not “executing workflow” on the test situation, I get an error that is a json message that looks like this:

{
    "code": 404,
    "hint": "Click the 'Execute workflow' button on the canvas, then try again. (In test mode, the webhook only works for one call after you click this button)",
    "message": "The requested webhook \"GET 4cf859a3-515c-4dbf-8066-7ec9ef97f186\" is not registered."
}

if I do the same for production, I get:

HTTP/1.1 404 Not Found
Connection: keep-alive
Content-Encoding: gzip
Content-Security-Policy: default-src 'none'
Content-Type: text/html; charset=utf-8
Date: Mon, 22 Nov 2021 22:43:57 GMT
Strict-Transport-Security: max-age=15724800; includeSubDomains
Transfer-Encoding: chunked
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Powered-By: Express

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot GET /webhook/4cf859a3-515c-4dbf-8066-7ec9ef97f186</pre>
</body>
</html>

I’m self hosted, using docker and an nginx reverse proxy to get my requests into the container. I can reproduce the same behavior by using curl localhost:5678/webhook-test/XXX (it works) or curl localhost:5678/webhook/XXX (it doesn’t). These curl commands within the container bypass the nginx so im talking directly to the node process that is running n8n.

I know about the post vs get thing too, but in this case, the only difference is the removal of “-test” from the URL path, so nothing should be different there.

As I said before, I’m using the webhook node. It’s weird to me that im getting back some HTML with a 404 in the case of /webhook/xxx and json with /webhook-test/xxx.

I’ve done the save and activate, but no luck :frowning:

Any ideas?

If you set N8N_DISABLE_PRODUCTION_MAIN_PROCESS=true, you can reproduce this issue. Removing this env var resolved the issue for @danny and I

Welcome to the community @Noah_Schairer !

What you describe is exactly what should happen. You tell n8n to not register any production webhooks, so it does not.
So I am very confused. Why do you set that environment variable if you do not want to happen what it controls?

We just made a mistake and didn’t finish reading the documentation! We assumed workers would start up automatically or something, and then never changed back the env variable.

Ah OK makes sense.

Generally for other people reading this topic. That environment variable should normally never be set. The only time where it is needed, is if scaling mode is used with separate webhook services and the main process should not be allowed to process any requests itself.