# How can i stop and then restart the Node-Red application with runtime API?

**URL:** <https://discourse.nodered.org/t/how-can-i-stop-and-then-restart-the-node-red-application-with-runtime-api/40268>\
**Category:** General\
**Created:** [2 February 2021 21:44 UTC](https://discourse.nodered.org/t/how-can-i-stop-and-then-restart-the-node-red-application-with-runtime-api/40268 "2021-02-02T21:44:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Norberg95](https://avatars.discourse-cdn.com/v4/letter/n/848f3c/32.png) [@Norberg95](https://discourse.nodered.org/u/Norberg95)\
**Post date:** [2 February 2021 21:44 UTC](https://discourse.nodered.org/t/how-can-i-stop-and-then-restart-the-node-red-application-with-runtime-api/40268/1 "2021-02-02T21:44:22Z")

</div>

I would like to close every flow and then restart them from the runtime API.  
I am testing this code, but it crashes.

```auto
RED.start();

setTimeout(() => {

    console.log('RED starting to stop');

    RED.stop().then(() => {

      console.log('RED stopped');

    });

    setTimeout(() => {

      console.log('RED starting to start');

      RED.start().then(() => {

        console.log('RED started');

      });

    }, 15000);

  }, 15000);

```

I am getting the following errors.

```auto
> 22:40:00.924 ERROR [JS] TypeError: Cannot read property 'handleUpgrade' of null
> at Server.upgrade (c:\dev\app\voc-builder-example-app\components\voc-builder\node_modules\@node-red\editor-api\lib\editor\comms.js:226:30)
> at Server.emit (events.js:194:13)
> at onParserExecuteCommon (_http_server.js:566:14)
> at onParserExecute (_http_server.js:506:3)
> 22:40:01.068 INFO [JS] TypeError: Cannot read property 'handleUpgrade' of null
> at Server.upgrade (c:\dev\app\voc-builder-example-app\components\voc-builder\node_modules\@node-red\editor-api\lib\editor\comms.js:226:30)
> at Server.emit (events.js:194:13)
> at onParserExecuteCommon (_http_server.js:566:14)
> at onParserExecute (_http_server.js:506:3)

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [3 April 2021 21:45 UTC](https://discourse.nodered.org/t/how-can-i-stop-and-then-restart-the-node-red-application-with-runtime-api/40268/2 "2021-04-03T21:45:24Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
