Can't POST from local machine

I have this flow that works nicely when I try to access the HTTP IN node via an external machine

curl "http://192.168.50.59:1880/callback_google_meet_url" -X POST  -d "test"

However, if I try connect it locally it doesn't work:

curl "http://localhost:1880/callback_google_meet_url" -X POST  -d "test"

or

curl "http://127.0.0.1:1880/callback_google_meet_url" -X POST  -d "test"

I just got this error message:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot POST /calback_google_meet_url</pre>
</body>
</html>

Here's the flow that I'm using

[{"id":"6bf330e3.7c886","type":"tab","label":"Debug","disabled":false,"info":""},{"id":"f2ba6c03.8e3da","type":"http in","z":"6bf330e3.7c886","name":"Callback with the Google Meet URL","url":"callback_google_meet_url","method":"post","upload":false,"swaggerDoc":"","x":500,"y":340,"wires":[["bc26fc08.625b4","f7130f73.285d2"]]},{"id":"bc26fc08.625b4","type":"debug","z":"6bf330e3.7c886","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":850,"y":400,"wires":[]},{"id":"f7130f73.285d2","type":"http response","z":"6bf330e3.7c886","name":"","statusCode":"","headers":{},"x":830,"y":280,"wires":[]}]

silly question (but someone has to ask) ...

is the curl command being executed on the same machine that node-red is running on?

does the debug show anthing when you curl to localhost?

can you change the debug to show complete msg - do you see clues in the full msg object?

I'm executing them on different machines:

Node-red machine: curl "http://localhost:1880/callback_google_meet_url" -X POST -d "test"
other machine: curl "http://192.168.50.59:1880/callback_google_meet_url" -X POST -d "test"

No debug for the local curl, event with the complete message

I also changed the http response code for 200 on the response node just in case

localhost wont work if you are not on the node-red machine - am i misunderstanding you?

Are you running node-red in a container such as Docker?

Oh no, I'm not that dumb :smiley:

The localhost curl is being executed locally on the raspberry pi where node-red is installed

Are you running node-red in a container such as Docker?

No, I'm not using a container

What does
curl "http://localhost:1880/"
show?

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"/>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<!--
  Copyright JS Foundation and other contributors, http://js.foundation

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<title>Node-RED</title>
<link rel="icon" type="image/png" href="favicon.ico">
<link rel="mask-icon" href="red&#x2F;images&#x2F;node-red-icon-black.svg" color="#8f0000">
<link rel="stylesheet" href="vendor/jquery/css/base/jquery-ui.min.css">
<link rel="stylesheet" href="vendor/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="red/style.min.css">
</head>
<body spellcheck="false">
<div id="red-ui-editor"></div>
<script src="vendor/vendor.js"></script>
<script src="red&#x2F;red.min.js"></script>
<script src="red&#x2F;main.min.js"></script>

</body>
</html>

That's ok then, it is very odd, your flow works for me. Either you have something blocking POST to localhost or it is an issue with node-red. What hardware/OS are you running on and what version of node-red and nodejs. The node-red version is at the bottom of the dropdown menu, you can get the nodejs version using
node -v

Rasbian running on a Raspberry Pi 4B 4gb

Node: v12.22.1
Node-red: v1.3.3

That should be ok. Does it work if you change it to a GET?

No, same thing.

So having changed it to a GET
curl "http://localhost:1880/"
works, but
curl "http://localhost:1880/callback_google_meet_url"
doesn't? Even though you are definitely running the curl command directly on the machine running node-red.

When you run the node-red editor in a browser which machine are you running the browser on and what URL are you using in the browser?

For speed reasons I use a remote machine, but it works on both.

BTW I've installed a fresh copy of rasbian and node-red and it's now working. No idea on why it wasn't before though

Thank you for your help <3

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.