IMD SolutionComputing LibraryShop main store

Troubleshooting

Stop Node-RED Docker healthcheck CPU spikes on an edge PC

Edge computing and IIoT Published 7 min read

Short answer

The official Node-RED Docker image ships a Docker HEALTHCHECK whose probe command boots a full second Node.js runtime inside the container to make one loopback HTTP request. On a controller-class CPU shared with a PLC runtime, that boot is the roughly 45% spike in htop. Disable the probe or swap it for a shell test in the compose file; the restart policy still recovers crashes.

On this page
  1. Why does healthcheck.js spike the CPU on my edge controller?
  2. How do I confirm the probe causes the spike?
  3. Why does the freeze last about four seconds?
  4. Does --no-healthcheck stop the container auto-restarting?
  5. What do I put in the compose file instead?
  6. How do I keep the container off the PLC task's core?
  7. Questions asked

Disable the probe — that is the whole fix when the probe is only expensive. The Node-RED Docker image declares a HEALTHCHECK whose command, node healthcheck.js, boots a second complete Node.js runtime inside the container on every interval, just to issue one HTTP request to the editor endpoint on loopback. On a desktop host that cost disappears into headroom; on a controller-class CPU shared with a PLC runtime and its web visualization it is the roughly 45% spike in htop, pinning the core when flows are busy at the same moment. Run the container with --no-healthcheck — or better, put healthcheck: disable: true or a cheaper test in the compose file. Crash recovery is untouched: the restart policy, not the healthcheck, brings Node-RED back. This bites hardest when running Node-RED beside PLC code on an edge PC, where one or two cores carry everything.

Why does healthcheck.js spike the CPU on my edge controller? #

Because every probe boots a second Node.js runtime: the image's Docker HEALTHCHECK runs node healthcheck.js on a fixed interval, and on a one- or two-core CPU that also carries a PLC runtime, that cold start is the roughly 45% jump you see in htop.

The Docker daemon schedules the probe on its own timer, independent of Node-RED's event loop, and runs whatever command the image declares — that is standard HEALTHCHECK behavior, not a fault in your flows. Inside the container, healthcheck.js makes an HTTP request against the local editor endpoint and exits 0 on a good response, 1 on anything else. The traffic never leaves loopback. Where the cost sits:

  • The daemon's timer on the host: negligible.
  • The fork into the container's namespace: low.
  • The Node.js interpreter booting to execute healthcheck.js: dominant on a controller-class core.
  • The loopback request and the editor's HTTP handler: low.

Treat the numbers as observations, not specifications: operators running the stock image on compact controllers beside a PLC runtime report the healthcheck.js process taking roughly half of one core for its duration, saturating it when flows run concurrently. On desktop-class hardware the same boot costs a few percent and nobody notices. If your load tracks the flows rather than the clock, the method in troubleshooting high CPU usage in a Node-RED agent applies instead of this one.

How do I confirm the probe causes the spike? #

Read the container, not your memory of it: docker inspect node-red returns the baked-in probe configuration under .Config.Healthcheck — the Test, Interval, Timeout, Retries and StartPeriod — and .State.Health returns the current Status, FailingStreak and per-probe Log entries with Start, End and ExitCode.

The examples assume the container is named node-red; substitute your own name.

docker inspect node-red

The output is JSON. Pull out the Healthcheck object under Config for the probe configuration the image declared or your run command overrode; pull out Health under State for the live results. The cadence you noticed — about one probe per minute on the compact units in the field reports — is whatever Interval says, so read it instead of assuming it. Then do the arithmetic on one illustrative log entry from the probe Log:

"Start": "2026-01-15T10:42:00.312Z"
"End": "2026-01-15T10:42:04.318Z"
"ExitCode": 1

Duration = End − Start = 10:42:04.318 − 10:42:00.312 = 4.006 s ≈ 4.0 s. Cross-check against the daemon's clock with docker events --filter event=health_status --filter container=node-red, which stamps every health transition. Decision: if the probe duration or the event timestamps line up with the freeze your operator reports, the probe is the blocking event — stop tuning the visualization stack. If every probe is short with ExitCode 0, the spike is pure cost; skip to the fix.

Why does the freeze last about four seconds? #

A healthy probe on a controller finishes in well under a second; a freeze that lands consistently near four seconds means the HTTP request is not being answered, and healthcheck.js sits out its connect or response timeout with the CPU held for the whole window.

Three conditions turn an expensive probe into a hanging one:

  • The editor is bound to one specific interface, so the loopback connect is refused or dropped.
  • The port changed in settings.js or through the environment, but the probe still targets the default.
  • The event loop is already blocked by a synchronous node, so the request queues behind it.

The script tells you which: the console.log lines in healthcheck.js ship commented out in the image, so uncomment them, restart the container, and watch docker logs -f node-red. The output shows the host and port the probe resolved and whether it got a response, a refusal, or a timeout. Decision: a refusal or a port mismatch is a configuration fault — fix the binding, or aim the replacement probe at the real URL. A timeout with the loop blocked is the probe doing its job: fix the blocking node first, because disabling the probe then only hides the stall.

Does --no-healthcheck stop the container auto-restarting? #

No. --no-healthcheck removes only the status probe; the restart policy, restart: unless-stopped, reacts to the main process exiting and brings Node-RED back whether a healthcheck exists or not.

The two mechanisms are independent. The restart policy watches the container's main process: if Node-RED is PID 1 and it dies, the container restarts with or without a probe — the exit-code path in detail is covered in auto restart Node-RED in Docker after exit code 255. Health status is a label: on stock Docker an unhealthy container keeps running until an orchestrator or a sidecar acts on it, so the probe was never your crash recovery. The options:

Option Setting Spike Crash recovery Health status
Disable the probe healthcheck: disable: true Gone Restart policy None
Stretch the interval healthcheck: interval: 5m Same peak, rarer Restart policy Kept
Shell HTTP test healthcheck: test with wget or curl Mostly gone Restart policy Kept
Process test healthcheck: test on the Node-RED process Gone Restart policy Kept, coarser

Decision: if nothing in your stack reads health status, disable it outright. If an orchestrator, dashboard or autoheal sidecar does read it, use the shell test. The process test is the fallback when the image carries no HTTP client, and note that it reports healthy on a hung event loop — exactly the condition the page fetch catches.

What do I put in the compose file instead? #

Put healthcheck: disable: true under the node-red service in your compose file so the change survives recreation, or replace the Node probe with a shell test once you have confirmed wget or curl exists in the image.

The --no-healthcheck flag is a docker run flag: per-container, and lost the moment anyone recreates the container from the image. The compose file is the durable place:

services:
  node-red:
    image: nodered/node-red   # pin the exact tag you deploy
    restart: unless-stopped
    healthcheck:
      disable: true

Keeping the status means replacing the test rather than deleting it. First verify a client is present — docker exec node-red sh -c 'command -v wget curl' — then point it at the same editor endpoint the Node probe used, including any port you configured:

    healthcheck:
      test: ["CMD-SHELL", "wget --spider http://127.0.0.1:1880 || exit 1"]

A shell probe costs a fork and a socket instead of a runtime boot. In-container edits are for diagnosis only; the compose file is the record of what the deployment actually does.

How do I keep the container off the PLC task's core? #

Cap the container with cpus: 0.5 (docker run: --cpus=0.5) so a runaway flow or an in-container package install can never take the whole core that also services the PLC runtime; removing the probe and fencing the CPU are two separate defenses.

Removing the probe removes one predictable spike. It does nothing about a runaway flow, a package install inside the container, or a node doing synchronous file I/O at an unpredictable moment. Read the core count with nproc from the controller shell, then:

  • One core: cap the share with cpus: 0.5. The CFS quota limits the container to half the available cycles, so the worst burst leaves the other half for everything running beside it.
  • Two or more cores: pin the container away from the core carrying the PLC task with a cpuset, and cap it anyway.

Verify the boundary through the task configuration of your controller application: reset the minimum, maximum and average cycle-time counters, let the controller run through several health intervals, and read them back. A maximum cycle time walking toward the watchdog limit means the fence is mandatory; an unchanged maximum with a stuttering web visualization means comfort, not control, is at stake. One limit to keep straight: a CFS quota shapes scheduling, it does not make a general-purpose operating system real-time, so nothing with hard timing obligations should depend on the container yielding.

Probe off in compose, CPU capped, pinned away where the cores allow — that is the complete fix.

Questions asked

Will Docker restart a container that turns unhealthy?

Not on its own. Stock Docker records health status but acts only when the main process exits, which is the restart policy's job. Something has to consume the status: an orchestrator such as Swarm or Kubernetes, or an autoheal sidecar that watches unhealthy containers and recreates them. If nothing in your stack does that, disabling the probe costs you monitoring only, not recovery.

Can I edit healthcheck.js inside the running container instead?

It works until the next image pull or container recreation, then the stock file returns and the spike comes back with it. The change lives only in that container's writable layer, so nothing in your repository records it. Use an in-container edit for the temporary diagnostic of uncommenting the logging lines, and put the permanent fix in the compose file.

What does FailingStreak in the health log mean?

It is the count of consecutive probes that returned a nonzero exit code. Docker flips the container's status from healthy to unhealthy once FailingStreak passes the Retries value baked into the image or set in your compose file, and resets it on the next passing probe. A FailingStreak that grows on every interval points to a persistent fault, not load.

Does a passing healthcheck prove my flows are running?

No. The probe only proves the editor's HTTP endpoint answered a request. It says nothing about whether flows are wired to real devices, whether MQTT is connected, or whether a slow node is delaying messages. For flow-level health, publish status from Node-RED itself and monitor it from outside the container.

Keep reading

  • How-to

    Run Python and Node-RED beside PLC code on an edge PC

    Keep the IEC 61131-3 program in the controller runtime and run Python and Node-RED as separate Docker containers on the same edge PC. Exchange data over one MQTT interface with a fixed publish period, and declare data stale after three missed periods. One container per workload, and nothing from Python or Node-RED inside the control project.

    Edge computing and IIoT

  • Troubleshooting

    Fixing a Docker shared library error on an edge PC

    A container on an edge PC that exits with an error while loading shared libraries was built for a different controller firmware generation than the one installed. Pull the image revision rebuilt for your firmware, recreate the container, and verify with ldd, the linker cache and a restart-count check. Never symlink across major library versions: on a machine driving physical outputs, a mismatched library produces wrong I/O data instead of a clean error.

    Edge computing and IIoT

  • How-to

    Install licensed software on an industrial edge PC

    Install vendor-licensed container software on an industrial edge PC by passing four gates in order: a purchased license with the installer obtained only from the vendor, a verified Docker engine, an installer build that matches the CPU, and a proven open-internet path before the pull. Vendor guidance budgets the install command at 30 minutes to 1 hour; at a 5 Mbit/s link a 2 GB payload alone needs about 53 of them.

    Edge computing and IIoT