How to Install Node-RED on a VPS with Docker: Visual Automation Without Much Code


Every morning you open the server dashboard, copy the disk usage numbers into the team chat, and repeat the same thing the next morning. Or a form on your site receives a message, and someone has to move it into a spreadsheet by hand. Jobs like these are not hard — just repetitive. And repetitive work done by a human will eventually be skipped once.

Node-RED solves that boredom in a different way from most automation tools: instead of writing long scripts, you arrange small boxes on a browser canvas and connect them with lines. One box fires on a schedule, the next fetches data from the internet, the next reshapes it, and the last sends the result where you want it. A finished flow can be understood at a glance, changed by dragging a new line, and run without redeploying anything. This guide installs Node-RED on a VPS with Docker Compose, then builds three real flows on top of it: a scheduled check, an API data check, and a webhook that receives data from outside.

Prerequisites

  • A Linux VPS with Docker and Docker Compose v2 installed.
  • SSH access to the VPS with sudo rights.
  • A domain already pointing at the VPS IP if you want HTTPS access, for example nodered.example.com. This guide uses that domain as an example; replace it with your own. Without a domain, you can still test the install at http://YOUR-VPS-IP:1880.
  • Port 1880 free on the VPS. This is Node-RED's default editor port.

Check Docker and Compose first:

docker --version
docker compose version

Expected result: both commands print a version number with no errors.

Step 1: create a working folder and set its owner

Create a folder at /opt/nodered and move into it:

sudo mkdir -p /opt/nodered/data
cd /opt/nodered

The data folder will hold everything Node-RED owns: the flow file flows.json, the credentials file flows_cred.json, and the settings file settings.js. Because the data lives in this host folder (not inside the container), your flows survive deleting and recreating the container — and this folder is what you will back up later.

One thing has to be sorted out from the start: inside the container, Node-RED runs as a user with UID 1000. The official Node-RED documentation states that the host data folder must be owned by the same UID, or Node-RED will not be able to write its flow files. Fix the ownership now:

sudo chown -R 1000:1000 /opt/nodered/data
ls -ld /opt/nodered/data

Expected result: the ownership line shows 1000 1000. If you work as a user with UID 1000 — usually the first user on the VPS — just run the sudo chown -R 1000:1000 command above; if your UID differs, check it with id and adjust the numbers.

Step 2: write the Compose file

Create a file called compose.yml:

sudo nano compose.yml

Fill it with the configuration below, following the Compose example in the official Node-RED Docker guide:

services:
  node-red:
    image: nodered/node-red:latest
    container_name: nodered
    environment:
      - TZ=Asia/Jakarta
    ports:
      - "1880:1880"
    volumes:
      - ./data:/data
    restart: unless-stopped

A quick explanation of each part: the image nodered/node-red:latest is the project's official image on Docker Hub — the repository was renamed to nodered/node-red in Node-RED 1.0, as the official documentation notes. TZ=Asia/Jakarta sets the container timezone, so schedule (inject) nodes run on your local time. Port 1880 is Node-RED's default port: the editor and every HTTP endpoint you create later are all served on this port. The volume ./data:/data mounts the host folder into the container's /data directory, where Node-RED stores all of its user settings according to the official docs.

Step 3: start it and check the container

Start the stack:

sudo docker compose up -d
sudo docker compose ps

Expected result: the nodered container shows as running (or Up). Node-RED needs a few seconds to prepare its initial files on first start. Check its logs:

sudo docker compose logs --tail=30 nodered

Expected result: lines like Settings file : /data/settings.js, Flows file : /data/flows.json, and finally Server now running at http://127.0.0.1:1880/. That last line is the sign Node-RED is ready to accept connections. You may also see a warning that the credentials file is encrypted with a system-generated key — that warning is dealt with in Step 7, where you set your own credentialSecret.

Test from inside the VPS that Node-RED responds:

curl -s -o /dev/null -w "%{http_code}\n" http://localhost:1880

Expected result: the number 200. If you get 000, the container is not ready yet or port 1880 is already used by another application — see the Troubleshooting section below.

Step 4: your first flow — Inject into Debug

Open http://YOUR-VPS-IP:1880 in a browser. You will see the Node-RED editor: an empty canvas in the middle, the node palette on the left, and an info panel on the right. There is no login yet — the editor is open without a password by default, and that will be fixed in Step 7 before Node-RED is exposed to the internet. For now, build the first flow.

From the palette on the left, drag an inject node onto the canvas, then drag a debug node and place it to its right. Connect them by dragging a line from the small dot on the right side of the inject node to the dot on the left side of the debug node. Double-click the inject node: leave its settings on the default — a timestamp payload — and click Done. Finally, click the red Deploy button at the top right.

Now click the small button on the left side of the inject node. The debug panel on the right will show a message containing the current timestamp. Simple, but this flow proves three things at once: the editor can save flows, the runtime runs them, and you can see the result. Every Node-RED flow, no matter how complex, is basically a chain like this — a message travels from one node to the next through the msg.payload property.

Step 5: a second flow — checking data from an API every ten minutes

A flow that only runs when a button is clicked does not feel like automation yet. Now build one that works on its own: every ten minutes it asks a public API for data, pulls one number out of the answer, and shows it.

Create a new flow tab (click the + above the canvas), then arrange these three nodes and connect them in order:

  1. An inject node — double-click it, change Repeat to an interval of every 10 minutes, and tick Inject once after 0.1 seconds so the flow runs once immediately when deployed.
  2. An http request node — set Method to GET and URL to https://api.github.com/repos/node-red/node-red. This node fetches the Node-RED repository data from the GitHub API, which can be used without an API key for occasional requests.
  3. A function node — fill it with this code:
msg.payload = "Node-RED stars on GitHub: " + msg.payload.stargazers_count;
return msg;

This small function takes the stargazers_count number from the JSON answer and turns it into one sentence.

  1. A debug node — leave it on the default, to display the final result.

Click Deploy, then watch the debug panel: within a few seconds a line like Node-RED stars on GitHub: 21400 will appear (the number changes with the current star count). The function node is the only place in this flow that uses JavaScript code — and it is just two lines. Everything else is set up by clicking. The same pattern — a scheduled trigger, an HTTP request, data processing, then showing or sending the result — works for checking prices, service status, or the weather; just change the URL and the field name.

Step 6: a third flow — a webhook that receives data from outside

Automation does not always start from a schedule; sometimes it has to respond to something arriving from outside, such as a website form or another service sending data to your server. Node-RED has an http in node for that: it opens an endpoint on your server, and anyone calling that endpoint triggers the flow.

On the same tab, arrange these three nodes:

  1. An http in node — set Method to POST and URL to /terima. This node creates an endpoint at http://YOUR-VPS-IP:1880/terima.
  2. A debug node — double-click it and change Output to complete msg object, so the full content of the incoming request is visible in the debug panel.
  3. An http response node — leave it on the default. This node ends the request with a 200 status.

Connect them in order: http in → debug → http response. Click Deploy, then test the endpoint from the VPS terminal:

curl -s -X POST http://localhost:1880/terima -H "Content-Type: application/json" -d '{"nama":"Budi","pesan":"Halo dari formulir"}'

Expected result: the terminal shows nothing (because the http response node was left empty), but the editor's debug panel will show the complete message object containing the nama and pesan you just sent. This endpoint can now be called by any service that can send an HTTP POST — and the flow behind it can grow: save to a file, forward to Telegram, or append to a spreadsheet. One important note: this endpoint is open to anyone who can reach port 1880, so do not expose it to the internet until Steps 7 and 8 are done.

Step 7: secure the editor with a login and a credential key

Node-RED without a login means anyone who reaches port 1880 can change and run your flows — including running commands through the exec node. The official Node-RED security guide is blunt about this: the editor and Admin API must be protected before Node-RED is used on a network other people can reach. This step adds a login with a bcrypt-hashed password, following the official guide.

First, create a password hash. Node-RED provides the node-red admin hash-pw command for this, and inside a Docker container it runs through npx:

docker exec -it nodered npx node-red admin hash-pw

Type the password you want when asked. The command prints a hash starting with $2a$ or $2b$ — copy the whole hash, because you will paste it into the settings file.

Open /opt/nodered/data/settings.js:

sudo nano /opt/nodered/data/settings.js

This file only appears after Node-RED has run for the first time. Find the adminAuth block, which is still commented out, remove the comment marks, and fill it with your user:

adminAuth: {
    type: "credentials",
    users: [{
        username: "admin",
        password: "PASTE-YOUR-BCRYPT-HASH-HERE",
        permissions: "*"
    }]
},

In the same file, find credentialSecret and set it to a long random string — for example the output of openssl rand -base64 24. Node-RED uses this value to encrypt the flows_cred.json file, where the credentials your flows use are stored. If you do not set it yourself, Node-RED uses a system-generated key and warns that the credentials file cannot be recovered if that key is lost. Do not use an example string from any article; generate a fresh one and keep it somewhere safe.

Save the file, then recreate the container:

cd /opt/nodered
sudo docker compose up -d

Open http://YOUR-VPS-IP:1880 again — the browser now shows a login page. Sign in with the user admin and the password you just hashed. If login fails, the pasted hash is most likely incomplete, or the adminAuth block is still inside a comment — re-check settings.js and try again.

Step 8: add a dashboard with Dashboard 2.0

A flow that is only visible in the editor cannot be used by anyone else. A dashboard turns flow data into a web page anyone you allow can open: numbers, buttons, and charts, without writing HTML. The package to use today is @flowfuse/node-red-dashboard — known as Dashboard 2.0 — because the old dashboard package (node-red-dashboard) has been discontinued since June 2024 and replaced by this one.

In the editor, open the menu at the top right, choose Manage Palette, switch to the Install tab, search for node-red-dashboard, and install the @flowfuse/node-red-dashboard package (not the old package of the same name without the @flowfuse/ prefix). Once installed, your palette gains nodes starting with ui, such as ui-text and ui-button.

Try one widget: drag a ui-text node onto the canvas, connect the inject node from Step 4 to it, then Deploy. Click the Open Dashboard button at the top right of the editor — the dashboard opens at /dashboard and shows the message from your flow. From here, adding a button that triggers a flow or a chart that shows numbers over time is just a matter of dragging another ui node onto the same canvas.

Step 9: put Nginx with HTTPS in front

Do not leave Node-RED on plain HTTP on port 1880 if this editor will be used from the internet — your login password travels over that connection. Create the file /etc/nginx/sites-available/nodered:

server {
    listen 80;
    server_name nodered.example.com;

    location / {
        proxy_pass http://127.0.0.1:1880;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

The two Upgrade and Connection headers above matter for Node-RED: the editor uses WebSocket to show node status and the debug panel live, and without those two headers the WebSocket connection fails to pass through the proxy. Enable the configuration and issue a certificate:

sudo ln -s /etc/nginx/sites-available/nodered /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
sudo certbot --nginx -d nodered.example.com

Expected result: nginx -t answers test is successful, and Certbot reports the certificate was issued. After that, open Node-RED at https://nodered.example.com and log in again with your admin account.

Step 10: set up backups and updates

Everything Node-RED owns — flows in flows.json, encrypted credentials in flows_cred.json, and settings in settings.js — lives in /opt/nodered/data. Backing up Node-RED is as simple as copying that one folder. Run the first manual backup now:

sudo tar -czf ~/nodered-backup-pertama.tar.gz -C /opt/nodered data
ls -lh ~/nodered-backup-pertama.tar.gz

Expected result: a small .tar.gz archive, usually tens to hundreds of kilobytes for a fresh install. Store it outside the VPS — download it to your computer or send it to another storage location. Note one thing: this archive contains flows_cred.json, encrypted with your credentialSecret, so keep that credentialSecret value safe and separate; without it, the credentials inside the backup cannot be opened again. Schedule this backup to repeat (for example with a weekly cron job) and make sure periodic backup archives really end up outside the VPS.

To update Node-RED to a new release, follow the standard Docker Compose pattern: pull the newest image, then recreate the container. Because the data lives in a host volume, your flows stay intact:

cd /opt/nodered
sudo docker compose pull
sudo docker compose up -d

After the update, open the editor and check that one flow still runs normally — for example, click the inject button from Step 4 and confirm the message appears in the debug panel.

Troubleshooting

curl returns 000 or the browser cannot connect. Check the container is running with sudo docker compose ps. If it shows Up but still does not respond, check the logs with sudo docker compose logs --tail=50 nodered. If the container will not start at all, port 1880 is probably already used by another application — check with sudo ss -tlnp | grep 1880, then change the port mapping in compose.yml to "1881:1880" and restart with sudo docker compose up -d. Remember, after changing the host port, the editor address changes to http://YOUR-VPS-IP:1881 as well.

Flows disappeared after the container was recreated. The ./data:/data volume was not mounted correctly, or you ran the container with a docker run command without -v, so the data lived inside the deleted container. Check the contents of /opt/nodered/data — if flows.json is there, your data is safe and the problem is the volume mapping in compose.yml. If the folder is empty, the lost flows cannot be recovered except from the backup in Step 10.

After setting adminAuth, login always fails. Most likely the hash pasted into settings.js is incomplete, or you edited the wrong settings.js file. The correct file is /opt/nodered/data/settings.js on the host — inside the container it sits at /data/settings.js. Check that the hash starts with $2a$ or $2b$ and that no characters were cut off. Fix it, then run sudo docker compose up -d again. If you are locked out completely, temporarily remove the adminAuth block from settings.js, recreate the container, log in, and repeat Step 7 more carefully.

The debug panel shows nothing and node status does not move. The editor's WebSocket connection is broken — this almost always happens when Node-RED sits behind a reverse proxy without the Upgrade and Connection headers. Check the Nginx block in Step 9, make sure both headers are there, then run sudo nginx -t and sudo systemctl reload nginx.

Installing a node from Manage Palette fails. Node-RED needs internet access to download packages from the npm registry. Check connectivity from inside the container with sudo docker exec nodered ping -c 2 registry.npmjs.org. If DNS on the VPS is broken, fix the host's DNS resolution first, then retry the package install.

flows_cred.json cannot be opened after moving to another server. The credentialSecret value on the new server differs from the one used when the credentials were saved. Set the same credentialSecret in settings.js as on the old server before Node-RED first runs on the new one. This is why that value must be stored separately from the backup.

Summary table

ComponentRolePortNotes
node-redFlow editor and runtime1880 → 1880Image nodered/node-red:latest
/opt/nodered/dataAll Node-RED data (flows.json, flows_cred.json, settings.js)—Volume /data; owner 1000:1000; this is what gets backed up
Inject nodeManual or scheduled flow trigger—Used in Steps 4 and 5
http request nodeCalls an API from inside a flow—Example: GitHub API in Step 5
http in / http response nodesWebhook endpoint that receives data—Example: POST /terima in Step 6
adminAuth + credentialSecretEditor login and credential encryption—Set in settings.js, Step 7
Dashboard 2.0Dashboard page built from flows (/dashboard)—Package @flowfuse/node-red-dashboard
Nginx on the hostReverse proxy + HTTPS + WebSocket80 / 443Upgrade header required for the editor
compose.ymlThe stack's only configuration file/opt/nodered/compose.ymlEditor has no login by default — secure it first

Check before you finish

  • ☐ The nodered container is running and curl http://localhost:1880 returns 200.
  • ☐ /opt/nodered/data is owned by 1000:1000 and contains flows.json and settings.js.
  • ☐ The Inject → Debug flow is deployed and the message appears in the debug panel.
  • ☐ The API-check flow runs on schedule and shows its result in the debug panel.
  • ☐ The POST /terima webhook has been tested with curl and its message is visible in the debug panel.
  • ☐ Admin login is active in the editor, replacing the default (no login) with a bcrypt-hashed login.
  • ☐ credentialSecret is set to your own value and stored separately from the backup.
  • ☐ Dashboard 2.0 is installed and one ui-text widget shows on /dashboard.
  • ☐ Node-RED is reachable at https://nodered.example.com (replace with your domain) with a valid certificate.
  • ☐ The first backup of /opt/nodered/data is made and stored outside the VPS.

The three flows above are only the beginning — the same pattern can connect a form to a spreadsheet, a sensor to a notification, or a schedule to a server command. After a week with Node-RED, which repetitive job do you want to automate first — regular reports, notifications, or syncing data between services? Tell us in the comments, and if any step above did not work on your VPS, paste the error message so it can be discussed together.

Read also: the Rnevio guide your first AI agent in n8n covers another flow automation tool you can compare with Node-RED, while the companion guide in this batch is how to install Zabbix on a VPS with Docker for server monitoring.

Diskusi

Ada pertanyaan atau pengalaman yang ingin dibagikan?

0komentar

Komentar ditinjau sebelum ditampilkan. Mari berdiskusi dengan sopan dan sesuai topik.