Node-RED IoT Platform
Node-RED flow-based programming for IoT with MQTT broker.
Overview
Node-RED is an open-source flow-based visual programming tool originally developed by IBM for wiring together hardware devices, APIs, and online services in IoT applications. Built on Node.js, it provides a browser-based flow editor that makes it easy to create event-driven applications using a wide range of pre-built nodes. The platform excels at rapid prototyping and deployment of IoT solutions, home automation systems, and data processing workflows without requiring traditional programming skills.
This stack combines Node-RED with Eclipse Mosquitto, a lightweight MQTT message broker that implements the MQTT protocol versions 5.0, 3.1.1, and 3.1. Mosquitto serves as the central communication hub for IoT devices, while Node-RED acts as the orchestration layer, processing MQTT messages and triggering automated responses. The integration enables real-time data collection from sensors, device control commands, and complex automation logic through Node-RED's visual drag-and-drop interface.
This configuration is ideal for IoT enthusiasts, home automation builders, and small-scale industrial deployments who need a powerful yet approachable platform for connecting and controlling smart devices. The combination provides enterprise-grade MQTT messaging capabilities with the flexibility of visual flow programming, making it accessible to both technical and non-technical users who want to build sophisticated IoT applications.
Key Features
- Flow-based visual programming with drag-and-drop node editor for creating IoT automation logic
- Built-in MQTT nodes for seamless publish/subscribe messaging with Mosquitto broker
- Over 4,000 community-contributed nodes available through npm for extending functionality
- Real-time dashboard creation with gauge, chart, and control widgets for IoT monitoring
- Function nodes supporting JavaScript for custom data processing and transformation
- WebSocket support for real-time browser-based device interaction and monitoring
- Eclipse Mosquitto MQTT 5.0 compliance with quality of service levels and retained messages
- Persistent flow storage with automatic backup and version control capabilities
Common Use Cases
- 1Home automation systems controlling smart lights, thermostats, and security sensors via MQTT
- 2Industrial IoT monitoring with sensor data collection and equipment status dashboards
- 3Greenhouse automation managing irrigation, climate control, and environmental monitoring
- 4Smart building management integrating HVAC, lighting, and occupancy sensors
- 5Weather station data aggregation with automated alerts and historical data logging
- 6Fleet vehicle tracking and monitoring using GPS and telemetry data over MQTT
- 7Energy monitoring systems tracking solar panels, battery storage, and consumption patterns
Prerequisites
- Docker Engine 20.10+ and Docker Compose V2 for container orchestration
- Minimum 512MB RAM for Node-RED container and 256MB for Mosquitto broker
- Available ports 1880 (Node-RED), 1883 (MQTT), and 9001 (MQTT WebSocket)
- Basic understanding of MQTT publish/subscribe messaging concepts
- Mosquitto configuration file (mosquitto.conf) with authentication and access control settings
- Network access for downloading Node-RED community nodes from npm registry
For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms
docker-compose.yml
docker-compose.yml
1services: 2 mosquitto: 3 image: eclipse-mosquitto:latest4 container_name: mosquitto5 restart: unless-stopped6 ports: 7 - "${MQTT_PORT:-1883}:1883"8 - "${MQTT_WS_PORT:-9001}:9001"9 volumes: 10 - mosquitto_data:/mosquitto/data11 - mosquitto_log:/mosquitto/log12 - ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro13 networks: 14 - iot-network1516 node-red: 17 image: nodered/node-red:latest18 container_name: node-red19 restart: unless-stopped20 ports: 21 - "${NODERED_PORT:-1880}:1880"22 environment: 23 - TZ=${TZ:-UTC}24 volumes: 25 - nodered_data:/data26 depends_on: 27 - mosquitto28 networks: 29 - iot-network3031volumes: 32 mosquitto_data: 33 mosquitto_log: 34 nodered_data: 3536networks: 37 iot-network: 38 driver: bridge.env Template
.env
1# Node-RED IoT2NODERED_PORT=18803MQTT_PORT=18834MQTT_WS_PORT=90015TZ=UTCUsage Notes
- 1Node-RED at http://localhost:1880
- 2MQTT broker at localhost:1883
- 3Create mosquitto.conf before starting
- 4Install MQTT nodes in Node-RED
Individual Services(2 services)
Copy individual services to mix and match with your existing compose files.
mosquitto
mosquitto:
image: eclipse-mosquitto:latest
container_name: mosquitto
restart: unless-stopped
ports:
- ${MQTT_PORT:-1883}:1883
- ${MQTT_WS_PORT:-9001}:9001
volumes:
- mosquitto_data:/mosquitto/data
- mosquitto_log:/mosquitto/log
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
networks:
- iot-network
node-red
node-red:
image: nodered/node-red:latest
container_name: node-red
restart: unless-stopped
ports:
- ${NODERED_PORT:-1880}:1880
environment:
- TZ=${TZ:-UTC}
volumes:
- nodered_data:/data
depends_on:
- mosquitto
networks:
- iot-network
Quick Start
terminal
1# 1. Create the compose file2cat > docker-compose.yml << 'EOF'3services:4 mosquitto:5 image: eclipse-mosquitto:latest6 container_name: mosquitto7 restart: unless-stopped8 ports:9 - "${MQTT_PORT:-1883}:1883"10 - "${MQTT_WS_PORT:-9001}:9001"11 volumes:12 - mosquitto_data:/mosquitto/data13 - mosquitto_log:/mosquitto/log14 - ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro15 networks:16 - iot-network1718 node-red:19 image: nodered/node-red:latest20 container_name: node-red21 restart: unless-stopped22 ports:23 - "${NODERED_PORT:-1880}:1880"24 environment:25 - TZ=${TZ:-UTC}26 volumes:27 - nodered_data:/data28 depends_on:29 - mosquitto30 networks:31 - iot-network3233volumes:34 mosquitto_data:35 mosquitto_log:36 nodered_data:3738networks:39 iot-network:40 driver: bridge41EOF4243# 2. Create the .env file44cat > .env << 'EOF'45# Node-RED IoT46NODERED_PORT=188047MQTT_PORT=188348MQTT_WS_PORT=900149TZ=UTC50EOF5152# 3. Start the services53docker compose up -d5455# 4. View logs56docker compose logs -fOne-Liner
Run this command to download and set up the recipe in one step:
terminal
1curl -fsSL https://docker.recipes/api/recipes/node-red-iot/run | bashTroubleshooting
- Node-RED flows not saving: Check that the /data volume has proper write permissions and sufficient disk space
- MQTT clients cannot connect to Mosquitto: Verify mosquitto.conf allows anonymous connections or configure proper authentication
- Node-RED MQTT nodes show 'disconnected': Ensure Mosquitto container is running and check network connectivity between containers
- WebSocket connections failing on port 9001: Confirm Mosquitto configuration includes WebSocket listener and port is not blocked by firewall
- Node-RED dashboard not loading: Clear browser cache and check that ui nodes are properly installed and configured
- High memory usage in Node-RED: Reduce debug node output retention and limit the number of active dashboard charts
Community Notes
Loading...
Loading notes...
Download Recipe Kit
Get all files in a ready-to-deploy package
Includes docker-compose.yml, .env template, README, and license
Components
node-redmosquitto
Tags
#node-red#iot#mqtt#automation#flow-programming
Category
Home Lab & Self-HostingAd Space
Shortcuts: C CopyF FavoriteD Download