# 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:** 1

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

</div>

I need to have seperate localfilesystems. I tried this config based on a forum example, yet noticed that when something is saved in "file" it also automatically gets saved in "file2" and "file3". I understand that there are base/dir parameters that can be added but can't figure out where/how. Thanks!

```auto

contextStorage: {
   default: "memoryOnly",
   memoryOnly: { module: 'memory' },
   file: { module: 'localfilesystem' },
   file2: { module: 'localfilesystem' },
   file3: { module: 'localfilesystem' }
},

```

---

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

</div>

The docs you need are here: [Working with context : Node-RED](https://nodered.org/docs/user-guide/context#using-multiple-context-stores)

In particular, the highlighted note:

> _Note_ : if you choose to configure multiple `localfilesystem` stores, you _must_ set their `dir` option so they use different directories to store data. Details on how to configure the store is available [here](https://nodered.org/docs/api/context/store/localfilesystem#options)

So in that case, you could do something like this (just make sure to update the `dir` values to real paths you have).

```auto
contextStorage: {
   default: "memoryOnly",
   memoryOnly: { module: 'memory' },
   file: { module: 'localfilesystem', dir: '/home/user/.node-red/context1' },
   file2: { module: 'localfilesystem', dir: '/home/user/.node-red/context2' },
   file3: { module: 'localfilesystem', dir: '/home/user/.node-red/context3' }
},

```

---

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

</div>

Hi, thanks!

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).

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

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [2 December 2022 18:29 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/4 "2022-12-02T18:29:24Z")

</div>

Have you added anything to those context stores?

Can you show us what you did to set a value in the other context stores?

---

<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:** [2 December 2022 18:35 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/5 "2022-12-02T18:35:19Z")

</div>

You can see some data in memory, some in default "file" (dir not specified in settings) and some in the "transact" file (which I can't locate)

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

```auto
flow.set('recordKeeper', check, 'transact');
flow.set('recordKeys', check, 'transact');

```

---

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

</div>

Does /home/ubuntu exist?  
Does /home/ubuntu/node-red exist (note, no dot)

---

<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:** [2 December 2022 21:55 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/7 "2022-12-02T21:55:07Z")

</div>

Yes, they exist

---

<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:** [2 December 2022 22:05 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/8 "2022-12-02T22:05:35Z")

</div>

Please stop node red then start it again in a terminal, then write something to the context store and stop node red again. Copy/paste the full log here. I don't know if it will tell us anything, but it may do.

---

<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:** [5 December 2022 21:28 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/9 "2022-12-05T21:28:36Z")

</div>

Where is the log file typically located?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [5 December 2022 23:45 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/10 "2022-12-05T23:45:28Z")

</div>

How are you running node-red? Installed locally? Via snap install? In a container (docker/home assistant/etc)

---

<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 00:28 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/11 "2022-12-06T00:28:02Z")

</div>

AWS linux ubuntu

---

<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 07:16 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/12 "2022-12-06T07:16:40Z")

</div>

When you run the command  
`node-red`  
The log appears in the terminal.

---

<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 07:17 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/13 "2022-12-06T07:17:29Z")

</div>

> [@interscope101](#):
>
> AWS linux ubuntu

That tells us nothing about how you installed node red.

---

<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 13:35 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/14 "2022-12-06T13:35:40Z")

</div>

Yes, I am aware of that. I was asking about location of the log file since I am not able to find it.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [6 December 2022 13:59 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/15 "2022-12-06T13:59:39Z")

</div>

Thats why you were asked

> [@Colin](#):
>
> When you run the command  
> `node-red`  
> The log appears in the terminal

So stop the node-red service and run (from it from a terminal as described) - you will see the node-red startup log and it will contain path details.

---

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

</div>

The commands that were suggested (in another post) to stop node-red service don't seem to be working in my case ...

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

Here is my directory structure with node-red install

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/6/b6cc89ca1402cbd559ac46f6f9ce354e7ef47224.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:20 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/17 "2022-12-06T15:20:05Z")

</div>

Here is what I get when I run node-red (while it's running)

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

---

<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 15:27 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/18 "2022-12-06T15:27:26Z")

</div>

How did you install Node-RED originally? Was it using the install script we provide?

If so, then do you have the commands `node-red-stop` and `node-red-start` ? Those would be the right way to start/stop the service.

The log output you've shared may be misleading if you're running as a different user - because it will be using the current user's home directory for its settings file. Given it is only logging about one context store (the default one), then I suspect it isn't picking up the same settings file as the service is.

So, if you did use our install script, then please try using `node-red-stop` and `node-red-start` to restart the service. You should also have `node-red-log` that get the recent log output.

If you installed some other way, then please share any details you can so we can track down exactly where it is running.

---

<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:31 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/19 "2022-12-06T15:31:18Z")

</div>

Installed using these instructions (ubuntu running on ec2)

[https://nodered.org/docs/getting-started/aws#running-on-aws-ec2-with-ubuntu](https://nodered.org/docs/getting-started/aws#running-on-aws-ec2-with-ubuntu)

Here is what I get with "node-red stop" (under both root and ubuntu user)

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

---

<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 15:42 UTC](https://discourse.nodered.org/t/context-file-not-written-when-using-multiple-localfilesystem-entries/71617/20 "2022-12-06T15:42:54Z")

</div>

Okay - so you installed and run it with `pm2` - is that correct?

In which case you will not have the `node-red-start` and `node-red-stop` commands (note they are one-word, not `node-red stop` as you have tried running).

If you run `pm2 list` what do you see?

To get to the logs, you would use `pm2 logs` with the name of the application from `pm2 list` that you want to see the logs for

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