Installing Node-RED
What this article covers
- How to install Node-RED using Docker or npm.
- How to configure and secure the basic setup.
- How to create your first flow.
- Which extensions (nodes) are essential.
- Troubleshooting common issues.
Introduction: Installing Node-RED explained
Node-RED is a visual flow editor where you connect nodes (building blocks) using drag-and-drop to create flows. Originally built for IoT, Node-RED excels at AI automation, Home Assistant integration, and data processing.
This article is for users looking to install Node-RED. For background, see Node-RED for AI automation and Docker basics.
Why do you need Node-RED?
Imagine you want to process sensor data, react to MQTT messages, or connect APIs. Instead of writing scripts, you drag nodes onto a canvas and connect them. Node-RED shines for event-driven automation, especially in IoT and smart home scenarios.
Node-RED installation in a nutshell
Node-RED is built on Node.js. The easiest way to install it is with Docker. Open the editor in your browser on port 1880 and build flows with drag-and-drop.
The core idea: visual programming for data flows.
Who is this article for?
- Self-hosters wanting to install Node-RED.
- IoT users automating sensors and devices.
- Automation builders creating event-driven flows.
- Home Assistant users needing complex automations.
Key concepts
- Node-RED - Visual flow editor. Use when: you need the tool itself.
- Flow - Connected nodes. Use when: building an automated process.
- Node - Individual building block. Use when: for triggers, processing, or output.
- Palette - Node library. Use when: installing extensions.
- Docker - Containers. Use when: setting up installations.
- MQTT - IoT protocol. Use when: handling sensor data.
- Home Assistant - Smart home platform. Use when: automating your home.
Installing with Docker
Basic installation
docker run -d \
--name nodered \
-p 1880:1880 \
-v nodered_data:/data \
--restart unless-stopped \
nodered/node-red:latest
Open your browser: http://localhost:1880
With Docker Compose
version: "3.8"
services:
nodered:
image: nodered/node-red:latest
container_name: nodered
restart: unless-stopped
ports:
- "1880:1880"
environment:
- TZ=Europe/Berlin
volumes:
- nodered_data:/data
networks:
- automation
volumes:
nodered_data:
networks:
automation:
driver: bridge
docker compose up -d
Installing with npm
# Install Node.js (if not already installed)
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
# Install Node-RED
sudo npm install -g --unsafe-perm node-red
# Start it
node-red
As a systemd service
# /etc/systemd/system/nodered.service
[Unit]
Description=Node-RED
After=network.target
[Service]
Type=simple
User=nodered
ExecStart=/usr/bin/node-red
Restart=on-failure
Environment=NODE_RED_OPTIONS=-v
[Install]
WantedBy=multi-user.target
sudo systemctl enable nodered
sudo systemctl start nodered
Basic configuration
settings.js
// /data/settings.js (Docker) or ~/.node-red/settings.js
module.exports = {
// Admin authentication
adminAuth: {
type: "credentials",
users: [{
username: "admin",
password: "$2b$08$...", // bcrypt hash
permissions: "*"
}]
},
// Port and host
uiPort: process.env.PORT || 1880,
uiHost: "0.0.0.0",
// HTTPS (for production)
// https: {
// key: require("fs").readFileSync("/data/privkey.pem"),
// cert: require("fs").readFileSync("/data/fullchain.pem")
// },
// Context storage
contextStorage: {
default: { module: "localfilesystem" }
},
// Logging
logging: {
console: {
level: "info",
metrics: false,
audit: false
}
}
};
Generating a password hash
# Inside the Node-RED container
docker exec -it nodered npx node-red admin hash-pw
# Or locally
npx node-red admin hash-pw
Your first flow
Hello World
- Drag an Inject Node onto the canvas.
- Drag a Debug Node next to it.
- Connect them (click the output → drag to the input).
- Click “Deploy”.
- Click the Inject button → the Debug panel shows the output.
HTTP endpoint
[HTTP In] → [Function] → [HTTP Response]
HTTP In: GET /api/hello
Function: msg.payload = { message: "Hello from Node-RED" }; return msg;
HTTP Response: 200
Test it: curl http://localhost:1880/api/hello
Installing essential nodes
Palette Manager
- Menu → “Manage palette”
- Tab “Install”
- Search and install
Recommended nodes
| Node | Purpose |
|---|---|
| node-red-dashboard | UI dashboards |
| node-red-contrib-home-assistant-websocket | Home Assistant |
| node-red-contrib-mqtt-broker | MQTT server |
| node-red-node-email | |
| node-red-contrib-influxdb | InfluxDB |
| node-red-contrib-postgres | PostgreSQL |
| node-red-contrib-ollama | Ollama integration |
# Install via npm
cd /data
npm install node-red-dashboard node-red-contrib-home-assistant-websocket
Ollama in Node-RED
// Function Node: call Ollama
const response = await fetch("http://ollama:11434/api/chat", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
model: "llama3.1",
messages: [
{ role: "user", content: msg.payload }
],
stream: false
})
});
const data = await response.json();
msg.payload = data.message.content;
return msg;
Alternatively, use the node-red-contrib-ollama node for simpler integration. See Node-RED AI integration.
Connecting to Home Assistant
[events: state] → [switch] → [call service]
events: state:
Entity: sensor.temperature
If state: > 25
call service:
Domain: climate
Service: set_temperature
Data: {"temperature": 21}
Security notes
- Enable admin auth: Otherwise, anyone can modify your flows.
- Use HTTPS: For external access, enable TLS. See TLS certificates.
- Don’t expose: Never put Node-RED on the internet without authentication.
- Firewall: Keep port 1880 internal or behind a reverse proxy.
- Backup: Back up your
/datadirectory (contains flows and settings). See Backup.
Troubleshooting
Node-RED won’t start
# Check logs
docker logs nodered
# Common causes:
# - Port 1880 already in use
# - Corrupted settings.js
# - Node.js version too old
Nodes missing after restart
# Install nodes persistently
# In settings.js:
# externalModules: { autoInstall: true }
# Or in Docker:
docker exec -it nodered npm install node-red-dashboard
Flows disappeared after update
# Flows are stored in /data/flows.json
# If volume isn't mounted: flows are lost
# Always mount volume: -v nodered_data:/data
Common pitfalls
- No authentication enabled: Node-RED is open by default. Always set adminAuth.
- No volume mounted: Without a volume, flows are lost when the container restarts.
- Wrong Node.js version: Node-RED requires Node.js 18+.
- Docker networking:
localhostin a flow refers to the container, not the host. - Too many nodes installed: Each extension expands the attack surface. Install only what you need.
Further reading
- Node-RED for AI automation - Detailed guide to Node-RED.
- Node-RED AI integration - Integrating AI in Node-RED.
- Node-RED Home Assistant - Home Assistant integration.
- Installing n8n - Alternative to Node-RED.
- Docker basics - Understanding Docker.
- Workflow automation - Fundamentals.
Key takeaways:
- Node-RED is a visual flow editor, ideal for IoT and event-driven automation.
- Install via Docker (recommended) or npm.
- Admin auth and HTTPS are required for production.
- Add extensions through the Palette Manager or npm.
- Always mount a volume, or your flows will be lost.
FAQ
What is Node-RED?
How do I install Node-RED?
What port does Node-RED run on?
Node-RED or n8n?
How do I secure Node-RED?
Which extensions do I need?
How do I connect Node-RED to Home Assistant?
How do I back up my flows?
Can I use Ollama in Node-RED?
Sources and further reading
- Node-RED - Official website.
- Node-RED Docker - Docker installation guide.
- Node-RED Library - Node and flow library.
- Node.js - Node.js runtime.


