Node-RED HTTP Node — Complete Guide
In this tutorial, you'll learn about Node. We cover key concepts, practical examples, and best practices.
Hook
You create an HTTP Input node to expose a REST endpoint. You deploy the flow and try curl http://localhost:1880/api/hello. You get "404 Not Found" or "Cannot GET /api/hello." The endpoint simply does not exist.
The Wrong Way
Running Node-RED on a port that is already in use (like port 80 or 443) without proper configuration causes the HTTP node to fail silently.
# BAD: Binding to port 80 without root or proper auth
# Node-RED settings.js:
uiPort: 80
Error: listen EACCES: permission denied 0.0.0.0:80
Node-RED did not start
Ports below 1024 require root privileges or CAP_NET_BIND_SERVICE capability.
The Right Way
Check the HTTP node URL, method, and ensure Node-RED is listening on the expected port.
# 1. Check which port Node-RED is actually using
curl -s http://localhost:1880/
<html><head><title>Node-RED</title></head><body>...</body></html>
Node-RED is running on port 1880.
# 2. Check the HTTP Input node configuration
# Double-click the HTTP node in the editor:
# - Method: GET
# - URL: /api/hello
# - Name: (optional)
# 3. Test the endpoint with the correct URL
curl -v http://localhost:1880/api/hello
* Connected to localhost (127.0.0.1) port 1880
> GET /api/hello HTTP/1.1
< HTTP/1.1 200 OK
Hello, World!
# 4. If 404, check if the flow is deployed
curl -s http://localhost:1880/flows | jq '.flows[] | select(.label == "My Flow") .active'
true
If the flow is active but the URL still does not work:
# 5. Check for URL conflicts
# Another HTTP node might be using the same URL
curl -s http://localhost:1880/flows | jq '[.flows[].nodes[] | select(.type == "http in") | {url: .url, method: .method}]'
[
{"url": "/api/hello", "method": "GET"},
{"url": "/api/hello", "method": "POST"}
]
Two HTTP nodes using the same URL and method — Node-RED uses the last one deployed. Change one URL.
Prevention
- Give each HTTP endpoint a unique URL and method combination.
- Use the HTTP Response node to send responses back — any HTTP Input node must be paired with an HTTP Response node.
- Group HTTP endpoints under a common prefix (
/api/,/<a href="/backend/webhooks/">webhook</a>/). - Test with
curlbefore testing with external tools. - Set
httpNodeRoot: "/api"in settings.js to prefix all HTTP Input nodes.
Common Mistakes with red http node
- Mixing let bindings with <- bindings in do notation, producing type errors
- Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors
- Non-exhaustive pattern matches that compile with warnings then crash at runtime
These mistakes appear frequently in real-world NODE code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
DodaTech — HTTP endpoints that respond correctly.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro