# Node-red dashboard "refused to connect"

**URL:** <https://discourse.nodered.org/t/node-red-dashboard-refused-to-connect/88224>\
**Category:** General\
**Tags:** node-red-dashboard\
**Created:** [24 May 2024 08:50 UTC](https://discourse.nodered.org/t/node-red-dashboard-refused-to-connect/88224 "2024-05-24T08:50:29Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [17 June 2024 20:12 UTC](https://discourse.nodered.org/t/node-red-dashboard-refused-to-connect/88224/21 "2024-06-17T20:12:21Z")

</div>

Well that is definitely corrupt, it is just a load of unprintable characters.

Have you upgraded to the latest node-red so that you can see if that helps?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [17 June 2024 20:15 UTC](https://discourse.nodered.org/t/node-red-dashboard-refused-to-connect/88224/22 "2024-06-17T20:15:48Z")

</div>

@jbudd this only happens when there is a power outage, so it probably isn't anything to do with the specific flows.

@larro96 The best thing might be to get a UPS to power the pc, or even a refurbished laptop so that it survives power failure for a while.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [17 June 2024 20:45 UTC](https://discourse.nodered.org/t/node-red-dashboard-refused-to-connect/88224/23 "2024-06-17T20:45:59Z")

</div>

> [@Colin](#):
>
> this only happens when there is a power outage

I don't really know when persistent context is actually written to the file and the buffer flushed but it seems more likely after a power outage that the file would be left with outdated but coherent data than nulls or other gibberish. Unless of course it's the file write process which triggers a crash.

So I wonder if it actually becomes corrupt when the flow first accesses it after a restart.

Maybe there are clues in the code of the flow.  
Maybe it would be worth checking the context files before starting Node-red.  
Perhaps watch the context directories to identify when files are modified.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 June 2024 07:56 UTC](https://discourse.nodered.org/t/node-red-dashboard-refused-to-connect/88224/24 "2024-06-18T07:56:35Z")

</div>

> [@jbudd](#):
>
> I don't really know when persistent context is actually written to the file and the buffer flushed but it seems more likely after a power outage that the file would be left with outdated but coherent data

Certainly, and I believe the s/w takes care to minimise the risk of corruption. Normally when that happens it is actually the fault of the hardware/OS, a power down during the write and the the file system not able to automatically roll back the half written data. This can happen on an SD card for example, but I presume this system is not on such a card, and the file system in use is NTFS or whatever Windows uses nowadays. So corruption should not happen.

> [@jbudd](#):
>
> So I wonder if it actually becomes corrupt when the flow first accesses it after a restart.

I don't see how the restart would know that that there had been a power failure.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [18 June 2024 08:24 UTC](https://discourse.nodered.org/t/node-red-dashboard-refused-to-connect/88224/25 "2024-06-18T08:24:37Z")

</div>

> [@Colin](#):
>
> So corruption should not happen.

> [@larro96](#):
>
> Okay, if I turn off the PC now for a weekend then I will get the same problem when I start the PC.

This statement implies that the problem can occur after a normal shutdown/reboot.  
Unless the OP also experiences operating system corruption and has not told us, it rather points to something confined to Node-red.

But I asked and they didn't share the flow so I'm not going to carry on guessing without evidence.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 June 2024 08:40 UTC](https://discourse.nodered.org/t/node-red-dashboard-refused-to-connect/88224/26 "2024-06-18T08:40:16Z")

</div>

> [@jbudd](#):
>
> This statement implies that the problem can occur after a normal shutdown/reboot.

True, but

> [@larro96](#):
>
> the corruption only happens after power outage.

Suggests the opposite. Clarification please @larro96

---

<div class="post-metadata">

**Author:** ![larro96](https://avatars.discourse-cdn.com/v4/letter/l/90db22/32.png) [@larro96](https://discourse.nodered.org/u/larro96)\
**Post date:** [18 June 2024 08:47 UTC](https://discourse.nodered.org/t/node-red-dashboard-refused-to-connect/88224/27 "2024-06-18T08:47:23Z")

</div>

[414336 240408.json](https://discourse.nodered.org/uploads/short-url/8QJyFdD9P946RGBdlGNp0Ku6QBK.json) (3.7 MB)  
I am going to check both what you and @Colin suggest.  
But I cannot do that whenever I want because the machine is in use in another country.  
I have some timeframes when I am allowed to remotely connect to the PC.

I've attached the flow.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [18 June 2024 09:05 UTC](https://discourse.nodered.org/t/node-red-dashboard-refused-to-connect/88224/28 "2024-06-18T09:05:40Z")

</div>

That file contains 16 flows!

---

<div class="post-metadata">

**Author:** ![larro96](https://avatars.discourse-cdn.com/v4/letter/l/90db22/32.png) [@larro96](https://discourse.nodered.org/u/larro96)\
**Post date:** [18 June 2024 09:21 UTC](https://discourse.nodered.org/t/node-red-dashboard-refused-to-connect/88224/29 "2024-06-18T09:21:23Z")

</div>

Yes, I don't know which flow can cause the error, if it is causing it.

---

<div class="post-metadata">

**Author:** ![larro96](https://avatars.discourse-cdn.com/v4/letter/l/90db22/32.png) [@larro96](https://discourse.nodered.org/u/larro96)\
**Post date:** [19 June 2024 19:00 UTC](https://discourse.nodered.org/t/node-red-dashboard-refused-to-connect/88224/30 "2024-06-19T19:00:02Z")

</div>

> [@jbudd](#):
>
> ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/e/1ee49fcea39505e487b16f6264fc0b010c050b1a.png)

This is the flow of b1531b115956bc02.  
[flow\_b1531b115956bc02.json](https://discourse.nodered.org/uploads/short-url/sNCfozJTxKksgWQ8b6cylJLci0l.json) (70.3 KB)

---

<div class="post-metadata">

**Author:** ![larro96](https://avatars.discourse-cdn.com/v4/letter/l/90db22/32.png) [@larro96](https://discourse.nodered.org/u/larro96)\
**Post date:** [19 June 2024 19:07 UTC](https://discourse.nodered.org/t/node-red-dashboard-refused-to-connect/88224/31 "2024-06-19T19:07:19Z")

</div>

This is the node that gets invalid at power outage.  
[node\_dcea7f832804799a.json](https://discourse.nodered.org/uploads/short-url/53zYvsFH5lcGydP7KwDQY3T7fjn.json) (1.2 KB)

---

<div class="post-metadata">

**Author:** ![larro96](https://avatars.discourse-cdn.com/v4/letter/l/90db22/32.png) [@larro96](https://discourse.nodered.org/u/larro96)\
**Post date:** [19 June 2024 19:21 UTC](https://discourse.nodered.org/t/node-red-dashboard-refused-to-connect/88224/32 "2024-06-19T19:21:26Z")

</div>

I've restarted the pc multiple times with node-red running but I can't force the corruption.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [19 June 2024 19:51 UTC](https://discourse.nodered.org/t/node-red-dashboard-refused-to-connect/88224/33 "2024-06-19T19:51:48Z")

</div>

You are injecting flow.session\_status and testing if it is true or false without checking if it is a boolean.  
Shouldn't be a problem but I wonder if it's worth checking:

```auto
if (typeof(session_status) === "boolean") {
// process it
}
else {
node.warn ("Invalid session_status")
}

```

And I see that the inject node repeats 10 times a second.  
There is an awful lot of setting and retrieving context variables going on here.  
What is the program doing 10 times per second?  
Could you get away with a lower frequency?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [19 June 2024 20:37 UTC](https://discourse.nodered.org/t/node-red-dashboard-refused-to-connect/88224/34 "2024-06-19T20:37:18Z")

</div>

Also can you show us how the context store is configured in settings.js please.

---

<div class="post-metadata">

**Author:** ![larro96](https://avatars.discourse-cdn.com/v4/letter/l/90db22/32.png) [@larro96](https://discourse.nodered.org/u/larro96)\
**Post date:** [20 June 2024 17:03 UTC](https://discourse.nodered.org/t/node-red-dashboard-refused-to-connect/88224/35 "2024-06-20T17:03:24Z")

</div>

```auto
* Runtime Settings
 * - lang
 * - runtimeState
 * - diagnostics
 * - logging
 * - contextStorage
 * - exportGlobalContextKeys
 * - externalModules
 ****************************************************************************** /

    /** Uncomment the following to run node-red in your preferred language.
     * Available languages include: en-US (default), ja, de, zh-CN, zh-TW, ru, ko
     * Some languages are more complete than others.
     */
    // lang: "de",

    /** Configure diagnostics options 
     * - enabled: When `enabled` is `true` (or unset), diagnostics data will
     * be available at http://localhost:1880/diagnostics  
     * - ui: When `ui` is `true` (or unset), the action `show-system-info` will 
     * be available to logged in users of node-red editor  
    */
    diagnostics: {
        /** enable or disable diagnostics endpoint. Must be set to `false` to disable */
        enabled: true,
        /** enable or disable diagnostics display in the node-red editor. Must be set to `false` to disable */
        ui: true,
    },
    /** Configure runtimeState options 
     * - enabled: When `enabled` is `true` flows runtime can be Started/Stoped 
     * by POSTing to available at http://localhost:1880/flows/state  
     * - ui: When `ui` is `true`, the action `core:start-flows` and 
     * `core:stop-flows` will be available to logged in users of node-red editor
     * Also, the deploy menu (when set to default) will show a stop or start button
     */
    runtimeState: {
        /** enable or disable flows/state endpoint. Must be set to `false` to disable */
        enabled: false,
        /** show or hide runtime stop/start options in the node-red editor. Must be set to `false` to hide */
        ui: false,
    },
    /** Configure the logging output */
    logging: {
        /** Only console logging is currently supported */
        console: {
            /** Level of logging to be recorded. Options are:
             * fatal - only those errors which make the application unusable should be recorded
             * error - record errors which are deemed fatal for a particular request + fatal errors
             * warn - record problems which are non fatal + errors + fatal errors
             * info - record information about the general running of the application + warn + error + fatal errors
             * debug - record information which is more verbose than info + info + warn + error + fatal errors
             * trace - record very detailed logging + debug + info + warn + error + fatal errors
             * off - turn off all logging (doesn't affect metrics or audit)
             */
            level: "info",
            /** Whether or not to include metric events in the log output */
            metrics: false,
            /** Whether or not to include audit events in the log output */
            audit: false
        }
    },

    /** Context Storage
     * The following property can be used to enable context storage. The configuration
     * provided here will enable file-based context that flushes to disk every 30 seconds.
     * Refer to the documentation for further options: https://nodered.org/docs/api/context/
     */
    contextStorage: {
        default: {
            module:"localfilesystem"
        },
    },

    /** `global.keys()` returns a list of all properties set in global context.
     * This allows them to be displayed in the Context Sidebar within the editor.
     * In some circumstances it is not desirable to expose them to the editor. The
     * following property can be used to hide any property set in `functionGlobalContext`
     * from being list by `global.keys()`.
     * By default, the property is set to false to avoid accidental exposure of
     * their values. Setting this to true will cause the keys to be listed.
     */
    exportGlobalContextKeys: false,

    /** Configure how the runtime will handle external npm modules.
     * This covers:
     * - whether the editor will allow new node modules to be installed
     * - whether nodes, such as the Function node are allowed to have their
     * own dynamically configured dependencies.
     * The allow/denyList options can be used to limit what modules the runtime
     * will install/load. It can use '*' as a wildcard that matches anything.
     */
    externalModules: {
        // autoInstall: false, /** Whether the runtime will attempt to automatically install missing modules */
        // autoInstallRetry: 30, /** Interval, in seconds, between reinstall attempts */
        // palette: { /** Configuration for the Palette Manager */
        // allowInstall: true, /** Enable the Palette Manager in the editor */
        // allowUpdate: true, /** Allow modules to be updated in the Palette Manager */
        // allowUpload: true, /** Allow module tgz files to be uploaded and installed */
        // allowList: ['*'],
        // denyList: [],
        // allowUpdateList: ['*'],
        // denyUpdateList: []
        // },
        // modules: { /** Configuration for node-specified modules */
        // allowInstall: true,
        // allowList: [],
        // denyList: []
        // }
    },

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [20 June 2024 17:39 UTC](https://discourse.nodered.org/t/node-red-dashboard-refused-to-connect/88224/36 "2024-06-20T17:39:24Z")

</div>

So the default settings for the file store. Do you still have the problem with the latest node red?

---

<div class="post-metadata">

**Author:** ![larro96](https://avatars.discourse-cdn.com/v4/letter/l/90db22/32.png) [@larro96](https://discourse.nodered.org/u/larro96)\
**Post date:** [20 June 2024 17:56 UTC](https://discourse.nodered.org/t/node-red-dashboard-refused-to-connect/88224/37 "2024-06-20T17:56:28Z")

</div>

I've changed the node to repeat every second instead.  
The program is counting how many seconds the online session has been established.

---

<div class="post-metadata">

**Author:** ![larro96](https://avatars.discourse-cdn.com/v4/letter/l/90db22/32.png) [@larro96](https://discourse.nodered.org/u/larro96)\
**Post date:** [20 June 2024 17:59 UTC](https://discourse.nodered.org/t/node-red-dashboard-refused-to-connect/88224/38 "2024-06-20T17:59:10Z")

</div>

I haven't managed to update yet.  
The machine is running locally without internet, how am I updating it the safest way without losing any data?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [20 June 2024 19:15 UTC](https://discourse.nodered.org/t/node-red-dashboard-refused-to-connect/88224/39 "2024-06-20T19:15:06Z")

</div>

Hopefully you have everything important backed up.

I don't know how to update node red without Internet access. How did you install it?

---

<div class="post-metadata">

**Author:** ![larro96](https://avatars.discourse-cdn.com/v4/letter/l/90db22/32.png) [@larro96](https://discourse.nodered.org/u/larro96)\
**Post date:** [22 June 2024 14:58 UTC](https://discourse.nodered.org/t/node-red-dashboard-refused-to-connect/88224/40 "2024-06-22T14:58:40Z")

</div>

Hopefully yes,  
I installed it with internet access but now it is running locally without internet access.

[Previous page](https://discourse.nodered.org/t/node-red-dashboard-refused-to-connect/88224.md?page=1)

[Next page](https://discourse.nodered.org/t/node-red-dashboard-refused-to-connect/88224.md?page=3)
