The Day Node-RED Ate My Disk (and How I Tamed It)

If you’ve ever woken up to your server screaming “No space left on device”, chances are you’ve been betrayed by… logs.
Yes, not hackers, not memory leaks, not some mysterious process — just plain, boring logs.

And if you’re running Node-RED in Docker, those logs can quietly grow until they’re bigger than your entire project. In my case? The Node-RED container log grew so fat it basically choked my server.

Let me share what happened — and how I fixed it.


Why Node-RED Logs Can Go Wild

Node-RED is amazing, but here’s the dark side:

  • Debug Nodes Gone Crazy
    That one debug node you forgot to turn off? Yeah, it’s been happily printing every single sensor reading, API response, or 2MB JSON object for weeks.
  • Docker’s “infinite” logging
    By default, Docker’s json-file log driver just keeps writing forever. No rotation, no limits. It’s like a diary with no last page.
  • Error Loops of Doom
    Got a misconfigured API call? Node-RED might retry every second and log every failure. Imagine that running for days.

How I Found the Culprit

First clue: my disk was full. Panic.
Second clue: Docker logs.

Here’s the magic command that revealed the monster:

sudo du -sh /var/lib/docker/containers/*/*-json.log | sort -hr | head -10

Boom. A single Node-RED log file weighing tens of gigabytes.


Quick “Oh Sh*t” Fix

If you’re already out of space, don’t uninstall half your server. Just nuke the log size:

sudo truncate -s 0 /var/lib/docker/containers/<container-id>/<container-id>-json.log

The container keeps running, you instantly free up space, and you can breathe again.
(But yeah, the old logs are gone. Worth it.)


Permanent Fix (So It Never Happens Again)

1. Tell Docker to Chill

Add this to your docker-compose.yml:

services:
  node-red:
    image: nodered/node-red
    logging:
      driver: "json-file"
      options:
        max-size: "50m"
        max-file: "5"

Now Docker rotates logs:

  • Max file size = 50 MB
  • Keeps only 5 files
  • Total = 250 MB, not 25 GB 😅

Then restart:

docker-compose down
docker-compose up -d

2. Clean Up Your Debug Nodes

  • Don’t log huge JSON objects to the console.
  • Disable Debug nodes you don’t need.
  • Use dashboards, databases, or file storage instead of turning your logs into a landfill.

3. Stay on Watch

Every now and then, run:

sudo find /var/lib/docker/containers/ -name "*-json.log" -size +100M

If logs are getting out of hand, you’ll know before your server does.


Final Thoughts

Node-RED didn’t mean to betray me. It’s like a cute puppy that poops everywhere if you don’t train it. 🐶

  • Short-term survival: truncate the logs.
  • Long-term health: enable Docker log rotation + tidy up Debug nodes.

Do this early, and you’ll never wake up to the dreaded “disk full” nightmare again.


👉 Pro tip: If you’re using Node-RED in production, log rotation is not optional. It’s the difference between smooth sailing and a server heart attack.

Related: How I Caught Node-RED Eating My Disk with ncdu.

Related: The Best Feature I Ever Shipped Was a One-Page Procedure.


Discover more from Susiloharjo

Subscribe to get the latest posts sent to your email.

Discover more from Susiloharjo

Subscribe now to keep reading and get access to the full archive.

Continue reading