Skip to content
BotServBotServ
Node-REDInstallationDockerFlow-EditorIoT

Install Node-RED

Install and configure Node-RED. Docker, npm, first flows, dashboard and troubleshooting.

S

schutzgeist

6 min read
Install Node-RED

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

  1. Drag an Inject Node onto the canvas.
  2. Drag a Debug Node next to it.
  3. Connect them (click the output → drag to the input).
  4. Click “Deploy”.
  5. 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

  1. Menu → “Manage palette”
  2. Tab “Install”
  3. Search and install
NodePurpose
node-red-dashboardUI dashboards
node-red-contrib-home-assistant-websocketHome Assistant
node-red-contrib-mqtt-brokerMQTT server
node-red-node-emailEmail
node-red-contrib-influxdbInfluxDB
node-red-contrib-postgresPostgreSQL
node-red-contrib-ollamaOllama 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}

See Node-RED Home Assistant.

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 /data directory (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: localhost in 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

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?

Node-RED is a visual flow editor. You connect nodes via drag-and-drop to build flows. Originally designed for IoT, it’s now widely used for AI automation and data processing.

How do I install Node-RED?

The easiest way is Docker: docker run -d -p 1880:1880 -v nodered_data:/data nodered/node-red:latest. Alternatively, use npm: npm install -g node-red.

What port does Node-RED run on?

Port 1880 by default. Open http://localhost:1880 in your browser to access the flow editor.

Node-RED or n8n?

Choose Node-RED for IoT, MQTT, and event-driven flows. Choose n8n for API integrations, SaaS connectors, and complex business workflows. Both can be connected to Ollama.

How do I secure Node-RED?

Enable adminAuth in settings.js, use HTTPS, don’t expose it to the internet, and configure your firewall. Without authentication, anyone can modify your flows.

Which extensions do I need?

node-red-dashboard for UIs, node-red-contrib-home-assistant-websocket for smart home, node-red-contrib-ollama for AI, node-red-node-email for email.

How do I connect Node-RED to Home Assistant?

Install node-red-contrib-home-assistant-websocket. Then you can react to entity state changes and call services. See Node-RED Home Assistant for details.

How do I back up my flows?

The /data directory contains flows.json and settings.js. Back up the Docker volume or export flows as JSON through the editor.

Can I use Ollama in Node-RED?

Yes, either through a Function node with fetch() or via node-red-contrib-ollama. Both must be on the same Docker network.

Sources and further reading

Back to Blog
Share:

Related Posts