# File node- not writing to file

**URL:** <https://discourse.nodered.org/t/file-node-not-writing-to-file/26404>\
**Category:** General\
**Created:** [10 May 2020 06:01 UTC](https://discourse.nodered.org/t/file-node-not-writing-to-file/26404 "2020-05-10T06:01:47Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [10 May 2020 06:01 UTC](https://discourse.nodered.org/t/file-node-not-writing-to-file/26404/1 "2020-05-10T06:01:48Z")

</div>

I have Node Red on two systems- I am slowly moving my flows to the new Intel NUC from the Raspberry Pi.  
One of the flows I want to move uses the file node to write to a log file. Works fine on the Raspberry Pi, but not on the NUC.

Here is the test flow (2 nodes, inject and file).  
`[{"id":"8c61e374.88ac6","type":"file","z":"4a11758.b10b38c","name":"","filename":"/home/steve/Documents/Garden/test.txt","appendNewline":true,"createDir":false,"overwriteFile":"true","encoding":"none","x":620,"y":1140,"wires":[[]]},{"id":"aa7a45d8.1fd168","type":"inject","z":"4a11758.b10b38c","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":300,"y":1140,"wires":[["8c61e374.88ac6"]]}]`

![file](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/1/c1957671df47a43f13619539cdea56a2e41f0339.jpeg)

When I first run the flow, I get an error message:  
`Error: ENOENT: no such file or directory, open '/home/steve/Documents/Garden/mytest.txt'`

Yet, on the NUC, I can `cd /home/steve/Documents/Garden`  
The file is not there, so I try creating one with a touch command. But still, the file node won't write to it.

I also tried reading from a file in that folder by creating a file with one line of text. This generates a similar error:  
`Error: ENOENT: no such file or directory, open '/home/steve/Documents/Garden/mytest.txt'`

So, any clues what's happening? is /home not /home on the NUC (running Ubuntu)?  
Any tips would be appreciated.

---

<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:** [10 May 2020 06:21 UTC](https://discourse.nodered.org/t/file-node-not-writing-to-file/26404/2 "2020-05-10T06:21:12Z")

</div>

What account does node-red run under? I'm guessing it runs as a service and probably doesn't have access to your personal files. Try putting files somewhere public with relaxed permissions.

---

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [10 May 2020 06:33 UTC](https://discourse.nodered.org/t/file-node-not-writing-to-file/26404/3 "2020-05-10T06:33:59Z")

</div>

Thanks, I am suspecting a permissions problem, so I set the folder and file permissions to 777. No difference.  
It appears that root owns node-red.  
But, can't root write to any folder regardless who owns it?

What do you mean by somewhere public?  
Also, why is Node-Red giving a "file not found" error if it is a permissions problem?

---

<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:** [10 May 2020 06:37 UTC](https://discourse.nodered.org/t/file-node-not-writing-to-file/26404/4 "2020-05-10T06:37:23Z")

</div>

> [@SteveMann](#):
>
> It appears that root owns node-red.  
> But, can't root write to any folder regardless who owns it?

Ownership is not the same as run time permissions. (i.e. root isn't running node-red (at least I hope not))

> [@SteveMann](#):
>
> What do you mean by somewhere public?

Accessible to all accounts.

---

<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:** [10 May 2020 08:14 UTC](https://discourse.nodered.org/t/file-node-not-writing-to-file/26404/5 "2020-05-10T08:14:08Z")

</div>

Put a debug node on the output of the node, there may be an error message there.

---

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [10 May 2020 14:52 UTC](https://discourse.nodered.org/t/file-node-not-writing-to-file/26404/6 "2020-05-10T14:52:03Z")

</div>

> [@SteveMann](#):
>
> What do you mean by somewhere public?
> 
> Accessible to all accounts.

I've set the folder ACL to nouser:nogroup and the permissions to 777. What else could I do to make it more public?

---

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [10 May 2020 14:58 UTC](https://discourse.nodered.org/t/file-node-not-writing-to-file/26404/7 "2020-05-10T14:58:51Z")

</div>

Thanks, but payload in == payload out. No other data but msg.payload

---

<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:** [10 May 2020 15:07 UTC](https://discourse.nodered.org/t/file-node-not-writing-to-file/26404/8 "2020-05-10T15:07:20Z")

</div>

What happens if you don't specify a path (only file name). Check node-red folder. Also, add a catch node wired to a debug node set to show complete message.

---

<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:** [10 May 2020 15:25 UTC](https://discourse.nodered.org/t/file-node-not-writing-to-file/26404/9 "2020-05-10T15:25:36Z")

</div>

You said you get the error when you first run the flow, do you mean that only happens the first time you hit the inject, but thereafter nothing happens?  
My experiments suggest that if it is a permissions folder then you should get an error saying that.  
I presume that you are running up to date node-red and nodejs.

---

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [10 May 2020 15:29 UTC](https://discourse.nodered.org/t/file-node-not-writing-to-file/26404/10 "2020-05-10T15:29:35Z")

</div>

I tried that- specifying only a filename. The file should be written to the root of Node-red, or to the user root, but who is the user when Node-Red is installed by Home Assistant in a container on the NUC running Ubuntu?

At any rate, I did, and a find search for the file:

```auto
sudo find / -name mytest.txt
/var/lib/docker/overlay2/85e3f33253de0aa2dda81ed06a8c4a471ff43e428319b2699431756acf6a25f5/merged/home/steve/Documents/Garden/mytest.txt
/var/lib/docker/overlay2/85e3f33253de0aa2dda81ed06a8c4a471ff43e428319b2699431756acf6a25f5/diff/home/steve/Documents/Garden/mytest.txt

```

Those files are inaccesible to me even as su.

---

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [10 May 2020 15:34 UTC](https://discourse.nodered.org/t/file-node-not-writing-to-file/26404/11 "2020-05-10T15:34:39Z")

</div>

> [@Colin](#):
>
> You said you get the error when you first run the flow, do you mean that only happens the first time you hit the inject, but thereafter nothing happens?  
> My experiments suggest that if it is a permissions folder then you should get an error saying that.  
> I presume that you are running up to date node-red and nodejs.

Yes. The error shows only once. If I change anything but the filename and redeploy, I never get the error message again.

It is a recent install, less than a month. Node-Red version 6.2.0  
_node -v_ returns v8.10.0

---

<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:** [10 May 2020 15:47 UTC](https://discourse.nodered.org/t/file-node-not-writing-to-file/26404/12 "2020-05-10T15:47:22Z")

</div>

> [@SteveMann](#):
>
> Node-Red version 6.2.0

Node-red is currently at version 1.0.6 or thereabouts

---

<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:** [10 May 2020 15:50 UTC](https://discourse.nodered.org/t/file-node-not-writing-to-file/26404/13 "2020-05-10T15:50:06Z")

</div>

I guess you need to ask on HA forum about this.

On a straight node-red install, things are a bit more straight forward IMO.

---

<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:** [10 May 2020 15:50 UTC](https://discourse.nodered.org/t/file-node-not-writing-to-file/26404/14 "2020-05-10T15:50:42Z")

</div>

> [@SteveMann](#):
>
> Node-Red is installed by Home Assistant in a container

You should have mentioned that you are running in a Docker container. If you want to write to the the host file system from a Docker container then you have to setup a Docker Volume to map the docker file out to the host (or there may be other ways, not sure). You can't just write to it, that is one of the main points of running in a container, it is constrained so it can't mess with your system.

---

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [10 May 2020 16:35 UTC](https://discourse.nodered.org/t/file-node-not-writing-to-file/26404/16 "2020-05-10T16:35:41Z")

</div>

Sorry- I am not well versed in docker, and this is the only container that I have ever used. I had no reason to believe that this could be the problem. I know that the docker IP address is different form the host IP address, but I had no clue that the file path was also hidden.

So, how do I make a docker volume and how do I map it to the real folder in Ubuntu?

---

<div class="post-metadata">

**Author:** ![LosinIt](https://avatars.discourse-cdn.com/v4/letter/l/439d5e/32.png) [@LosinIt](https://discourse.nodered.org/u/LosinIt)\
**Post date:** [10 May 2020 16:40 UTC](https://discourse.nodered.org/t/file-node-not-writing-to-file/26404/17 "2020-05-10T16:40:15Z")

</div>

Hi, @SteveMann. I was in the same boat a few days ago having never looked at Docker and finding that I have to use it for NR on my system. Though I find the page rather confusing (probably due to no Docker experience) I was able to do what you need to with the help from [https://nodered.org/docs/getting-started/docker](https://nodered.org/docs/getting-started/docker)

---

<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:** [10 May 2020 17:21 UTC](https://discourse.nodered.org/t/file-node-not-writing-to-file/26404/18 "2020-05-10T17:21:37Z")

</div>

A possible alternative may be not to use Docker.

---

<div class="post-metadata">

**Author:** ![LosinIt](https://avatars.discourse-cdn.com/v4/letter/l/439d5e/32.png) [@LosinIt](https://discourse.nodered.org/u/LosinIt)\
**Post date:** [10 May 2020 19:56 UTC](https://discourse.nodered.org/t/file-node-not-writing-to-file/26404/19 "2020-05-10T19:56:24Z")

</div>

> [@Colin](#):
>
> not to use Docker.

Not sure this was directed to me but in my case I can't run native on Arch Linux because QT requires Libicu which in turn needs nodejs to be a later version than NR will run on... dll hell. Been there, tried that.

---

<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:** [10 May 2020 20:47 UTC](https://discourse.nodered.org/t/file-node-not-writing-to-file/26404/20 "2020-05-10T20:47:18Z")

</div>

It was addressed to anyone who has problems with running in a container, I suppose. If you do have a good reason then that is what you have to do.

---

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [10 May 2020 21:05 UTC](https://discourse.nodered.org/t/file-node-not-writing-to-file/26404/21 "2020-05-10T21:05:25Z")

</div>

Not use docker? For two years people have been on my case for avoiding docker. I finally installed a project using docker, and the solution is to not use docker?

No wonder I'm confused.

[Next page](https://discourse.nodered.org/t/file-node-not-writing-to-file/26404.md?page=2)
