# Forcibly close an open node.js inspector

**URL:** <https://discourse.nodered.org/t/forcibly-close-an-open-node-js-inspector/102256>\
**Category:** Feature Requests\
**Created:** [26 November 2026 18:34 UTC](https://discourse.nodered.org/t/forcibly-close-an-open-node-js-inspector/102256 "2026-11-26T18:34:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [26 November 2026 18:34 UTC](https://discourse.nodered.org/t/forcibly-close-an-open-node-js-inspector/102256/1 "2026-11-26T18:34:53Z")

</div>

A while back, I noticed that something had changed, at least in Chromium-based browsers, not sure about others.

If you start Node-RED with node.js's `--inspect` flag and attach an inspector. Then if you kill the node-red process (common for testing the development of custom nodes), Node-RED no longer shuts down.

It appears to shut down, if you were running from a terminal command line, you will be back at the command prompt and Node-RED's log will tell you it stopped the flows.

But if you try to restart Node-RED, you cannot because the web port is still in use.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/6/c6e3d0163b1305d3659f8f171f57d9e37c15f1d1.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/e/be26284dc5a7b7920bdf8c5bc1bd7f2dec848833.png)

I would like to request that somewhere in the Node-RED startup process, something like the following be added:

```js
const inspector = require('node:inspector');

/** Close the Node.js inspector (and any attached debugger client)
 * so that process shutdown isn't held up waiting for the client to detach.
 */
function closeInspector() {
    // inspector.url() returns undefined when the inspector isn't active
    if ( inspector.url() === undefined ) return

    try {
        inspector.close()
    } catch (err) {
        console.error('[inspector-closer] Failed to close inspector:', err)
    }
}

// Forcably close any open inspector on process termination - otherwise, Node-RED does not cleanly close
process.once('SIGINT', closeInspector);
process.once('SIGTERM', closeInspector);

```

As far as I can tell, this has no downsides. Instead it makes the development workflow a lot smoother.
