# Context file not written when using multiple localfilesystem entries

**URL:** <https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617>\
**Category:** General\
**Created:** [2 December 2022 16:09 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617 "2022-12-02T16:09:03Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![interscope101](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@interscope101](https://discourse.nodered.org/u/interscope101)\
**Post date:** [6 December 2022 15:50 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/21 "2022-12-06T15:50:19Z")

</div>

> [@interscope101](#):
>
> Adding directories seemed to address the issue of data getting saved in their respective (specified) filesystems (without cross-saves) on the app side. However, oddly I cannot locate the new files in the specified directory, nor anywhere else in the drive (I searched).

By the way, this turned out to be incorrect. After I rebooted the server I noticed that the stored data appeared in ALL of the localfilesystems. It seems that the physical files don't really exist, it is some kind logical reference and everything is still getting stored in the same file.

---

<div class="post-metadata">

**Author:** ![interscope101](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@interscope101](https://discourse.nodered.org/u/interscope101)\
**Post date:** [6 December 2022 15:51 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/22 "2022-12-06T15:51:38Z")

</div>

Seems so ...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/b/ab7af6e3c5118827326aa5b6ed08063fcdaab71a.png)

---

<div class="post-metadata">

**Author:** ![interscope101](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@interscope101](https://discourse.nodered.org/u/interscope101)\
**Post date:** [6 December 2022 15:53 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/23 "2022-12-06T15:53:51Z")

</div>

So the command to get the logs would be ?  
What are my stop/stop commands?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [6 December 2022 16:01 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/24 "2022-12-06T16:01:31Z")

</div>

I must admit I haven't used pm2 in a long time - I think the docs you've followed should be updated to use a more standard install script that sets things up as a proper service ([Running on Raspberry Pi : Node-RED](https://nodered.org/docs/getting-started/raspberrypi))

To get the logs: `pm2 logs node-red`  
To stop `pm2 stop node-red`  
To start... possibly `pm2 start node-red`, if not, use the `pm2 start` command in the original doc you following.

---

<div class="post-metadata">

**Author:** ![interscope101](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@interscope101](https://discourse.nodered.org/u/interscope101)\
**Post date:** [6 December 2022 16:21 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/25 "2022-12-06T16:21:31Z")

</div>

> [@knolleary](#):
>
> pm2 logs node-red

Ok, the log is running - I see basically same notifications as from the debug nodes on the front end? No information regarding the context stores - they are taking placing continuously and I just did a few manually.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/a/8a98c30e720bc82ff99bad325b6dbb1629ee5556.png)

---

<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:** [6 December 2022 16:25 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/26 "2022-12-06T16:25:25Z")

</div>

We need to see the start of the log from when node-red starts

---

<div class="post-metadata">

**Author:** ![interscope101](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@interscope101](https://discourse.nodered.org/u/interscope101)\
**Post date:** [6 December 2022 16:26 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/27 "2022-12-06T16:26:33Z")

</div>

This is what going on as shown the context menu. Unfortunately this issue is somehow preventing my app from working properly. It starts working properly when I change (for testing purposes) to context.set (but I need permanent storage).

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

---

<div class="post-metadata">

**Author:** ![interscope101](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@interscope101](https://discourse.nodered.org/u/interscope101)\
**Post date:** [6 December 2022 16:29 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/28 "2022-12-06T16:29:43Z")

</div>

Ok ... pm2 stop/start node-red works. I opened another terminal to stop/start it while keeping log running. Here is what I got after start.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/1/219db91ee311abdb060b1e158d9633b5de452b81.png)

---

<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:** [6 December 2022 16:37 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/29 "2022-12-06T16:37:55Z")

</div>

If you make a simple flow with three inject nodes and change nodes writing simple data to the three file contexts and monitor them in the sidebar do they work correctly?

---

<div class="post-metadata">

**Author:** ![interscope101](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@interscope101](https://discourse.nodered.org/u/interscope101)\
**Post date:** [6 December 2022 16:48 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/30 "2022-12-06T16:48:42Z")

</div>

Everything "looks" correct ... saved three strings (with matching names) to three different file contexts .. problem is the actual files don't exist ..

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/a/7ae3618dfaf37d1da2f778182c500f02b77b39a7.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/6/a66b7669420d5529e259d05e1d67822742b151dd.png)

---

<div class="post-metadata">

**Author:** ![interscope101](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@interscope101](https://discourse.nodered.org/u/interscope101)\
**Post date:** [6 December 2022 16:54 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/31 "2022-12-06T16:54:29Z")

</div>

This is the context directory ... in each of those numbered dir (i.e. 096aa389d3b3c08b) there is a flow.json file; in global there is global.json

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/a/ba9a667fc0f8b01cf2e602e99a58cc8403d3bc9f.png)

---

<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:** [6 December 2022 16:55 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/32 "2022-12-06T16:55:53Z")

</div>

So are there two problems you are describing? Firstly that you can't find the files, and secondly that your real flow writes the same data to all stores?

In your test flow, if you restart node-red does it pick up the previous values without pressing inject?

---

<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:** [6 December 2022 16:58 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/33 "2022-12-06T16:58:02Z")

</div>

Also have a look in /home/ubuntu/node-red (not .node-red)

If they are not there show us that section of the settings file again.

---

<div class="post-metadata">

**Author:** ![interscope101](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@interscope101](https://discourse.nodered.org/u/interscope101)\
**Post date:** [6 December 2022 17:13 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/34 "2022-12-06T17:13:49Z")

</div>

Ok, restarted, this is odd ... the string "history" (that I saved in "history" file) after the restart is supposedly in all three of the contexts

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/2/422a8777422156044d8613aac6e252dff0830c4d.png)

Also, I took look inside those flow.json files - it seems those are in fact the context saves, is that correct? I was searching for actual names. However, the content doesn't make sense - two of them contain the duplicated record sets that I am seeing in the context menu

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/0/f0723b254c63b0b139000bf9ae36332ef8b30fe4.png)

and the third one is referencing the history string (only thing that's there)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/b/8bbabc1d4f887d7e4e2231d44b585e68c77a4de1.png)

---

<div class="post-metadata">

**Author:** ![interscope101](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@interscope101](https://discourse.nodered.org/u/interscope101)\
**Post date:** [6 December 2022 17:15 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/35 "2022-12-06T17:15:04Z")

</div>

> [@Colin](#):
>
> /home/ubuntu/node-red

/home/ubuntu/node-red is empty

---

<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:** [6 December 2022 17:18 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/36 "2022-12-06T17:18:06Z")

</div>

Can you export those seven nodes and paste them here please, also copy/paste the section of settings.js. Then we can test it. It is looking as if there may be an issue there.

---

<div class="post-metadata">

**Author:** ![interscope101](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@interscope101](https://discourse.nodered.org/u/interscope101)\
**Post date:** [6 December 2022 17:19 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/37 "2022-12-06T17:19:40Z")

</div>

nodes

```auto
[
    {
        "id": "e960b1e1d199e066",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "4c776138a2b4ec29",
        "type": "change",
        "z": "e960b1e1d199e066",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "#:(file)::file",
                "pt": "flow",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 500,
        "y": 280,
        "wires": [
            [
                "4a58933f3e3e4857"
            ]
        ]
    },
    {
        "id": "b53de7d1e1ec0fbf",
        "type": "inject",
        "z": "e960b1e1d199e066",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "file",
        "payloadType": "str",
        "x": 270,
        "y": 280,
        "wires": [
            [
                "4c776138a2b4ec29"
            ]
        ]
    },
    {
        "id": "52b31e0090c6cb2b",
        "type": "inject",
        "z": "e960b1e1d199e066",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "transact",
        "payloadType": "str",
        "x": 270,
        "y": 340,
        "wires": [
            [
                "b5a893a38da97580"
            ]
        ]
    },
    {
        "id": "85cec3a4c6b47ad3",
        "type": "inject",
        "z": "e960b1e1d199e066",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "history",
        "payloadType": "str",
        "x": 250,
        "y": 420,
        "wires": [
            [
                "c6b1349207913bc8"
            ]
        ]
    },
    {
        "id": "b5a893a38da97580",
        "type": "change",
        "z": "e960b1e1d199e066",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "#:(transact)::transact",
                "pt": "flow",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 500,
        "y": 340,
        "wires": [
            [
                "4a58933f3e3e4857"
            ]
        ]
    },
    {
        "id": "c6b1349207913bc8",
        "type": "change",
        "z": "e960b1e1d199e066",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "#:(history)::history",
                "pt": "flow",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 504.01300048828125,
        "y": 414.01043701171875,
        "wires": [
            [
                "4a58933f3e3e4857"
            ]
        ]
    },
    {
        "id": "4a58933f3e3e4857",
        "type": "debug",
        "z": "e960b1e1d199e066",
        "name": "debug 31",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 760,
        "y": 360,
        "wires": []
    }
]

```

---

<div class="post-metadata">

**Author:** ![interscope101](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@interscope101](https://discourse.nodered.org/u/interscope101)\
**Post date:** [6 December 2022 17:22 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/38 "2022-12-06T17:22:30Z")

</div>

from settings.js

```auto
     /** 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"
     // },
     //},

contextStorage: {
   default: "memoryOnly",
   memoryOnly: { module: 'memory' },
   file: { module: 'localfilesystem' },
   transact: { module: 'localfilesystem', dir: '/home/ubuntu/node-red/transact' },
   history: { module: 'localfilesystem', dir: '/home/ubuntu/node-red/history' }
},

     /** `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
      *

```

---

<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:** [6 December 2022 17:58 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/39 "2022-12-06T17:58:54Z")

</div>

What user have you told pm2 to run node red as?

---

<div class="post-metadata">

**Author:** ![interscope101](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@interscope101](https://discourse.nodered.org/u/interscope101)\
**Post date:** [6 December 2022 18:21 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/41 "2022-12-06T18:21:03Z")

</div>

I am not sure what takes place on load (whatever was set on install), If you're asking about today's start/stop tests, then ubuntu. If the question relates to write permissions, I have various node in the applications that are writing files in the /home/ubuntu directory.

[Previous page](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617.md?page=1)

[Next page](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617.md?page=3)
