# Exec node + Python3 Script on Ubuntu resulting in \[Errno 13\] Permission denied

**URL:** <https://discourse.nodered.org/t/exec-node-python3-script-on-ubuntu-resulting-in-errno-13-permission-denied/28021>\
**Category:** General\
**Created:** [9 June 2020 01:16 UTC](https://discourse.nodered.org/t/exec-node-python3-script-on-ubuntu-resulting-in-errno-13-permission-denied/28021 "2020-06-09T01:16:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![achirife](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@achirife](https://discourse.nodered.org/u/achirife)\
**Post date:** [9 June 2020 01:16 UTC](https://discourse.nodered.org/t/exec-node-python3-script-on-ubuntu-resulting-in-errno-13-permission-denied/28021/1 "2020-06-09T01:16:47Z")

</div>

Hi all,  
New to Node-Red and Ubuntu but I was moving fine ... until i crashed! Hope that you can help me clarify an issue that has been torturing me for a couple of days:

The Intended Flow that is not working: [Inject node] sends “hello…” string → [Exec node] calls Python3 script and passes the payload as parameter - This returns a JSON string → [Debug node] shows the JSON string returned from Exec node.

* * *

The issue - Exec node returns permission error:

Command failed: python3 /home/alex/ac\_work/python3/p3\_test\_1.py "Parameter-1"  
python3: can't open file '/home/alex/ac\_work/python3/p3\_test\_1.py': [Errno 13] Permission denied

* * *

Some facts:  
1 - If I go to Terminal and type the command used in the “exec” node, the script runs properly. It takes the parameter and returns the JSON string. No issues.  
2 - The directory where the python3 script is at has the following permissions:  
alex@alex-FX6860:~/ac\_work/python3$ ls -l  
total 8  
-rw-r--r-- 1 root root 14 Jun 8 20:10 nodered\_created\_file2.txt  
-rwxrwxrw- 1 alex ac\_nodered 422 Jun 8 16:15 p3\_test\_1.py  
alex@alex-FX6860:~/ac\_work/python3$  
3 - I created a simple output to file using the [File node], and the “nodered\_created\_file2.txt” got created. Notice that it has “root” as both owner and group.  
4 - Created a Group called ac\_nodered (users alex and root), and this is the Gropu in the directory where the python script resides.  
5 - Environment: Node-Red 1.0.6 running on Ubuntu 18.04.4 LTS, and started from the browser as URL [http://127.0.0.1:1880/](http://127.0.0.1:1880/)

Why is that this happens when, it appears that Node-RED is executing as root (all the reach of root), and also, root is one of the users in the group ac\_nodered that has "rwx" in that directory?

Any help will be greatly appreciated. Rgds,Alex

---

<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:** [9 June 2020 07:56 UTC](https://discourse.nodered.org/t/exec-node-python3-script-on-ubuntu-resulting-in-errno-13-permission-denied/28021/2 "2020-06-09T07:56:40Z")

</div>

Do you have a good reason for running as root? This is inherently risky as it gives node-red full access to trash your system in the case of a bug, accident or malicious intent.  
I would start by fixing that, so it is not running as root (did you see the [recommended Debian/Ubuntu/Pi install script](https://nodered.org/docs/getting-started/raspberrypi)?). Then fix the file permissions in your home folder  
`sudo chown -R alex:alex ~`  
and start again. This may not fix the problem but may throw light on what is going on.

---

<div class="post-metadata">

**Author:** ![achirife](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@achirife](https://discourse.nodered.org/u/achirife)\
**Post date:** [9 June 2020 12:54 UTC](https://discourse.nodered.org/t/exec-node-python3-script-on-ubuntu-resulting-in-errno-13-permission-denied/28021/3 "2020-06-09T12:54:35Z")

</div>

Hi Colin, thanks for your reply. I don't know why Node-Red is using 'root' user, and it was definitely not my intention. I didn't request that during installation of Node-Red.

How can I change the Ubuntu user that is being used by Node-Red to my user "alex"?

Thanks!

---

<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:** [9 June 2020 14:00 UTC](https://discourse.nodered.org/t/exec-node-python3-script-on-ubuntu-resulting-in-errno-13-permission-denied/28021/4 "2020-06-09T14:00:34Z")

</div>

How did you install it and how are you running it?  
Also please post the startup log you get when you run it.

---

<div class="post-metadata">

**Author:** ![achirife](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@achirife](https://discourse.nodered.org/u/achirife)\
**Post date:** [9 June 2020 18:25 UTC](https://discourse.nodered.org/t/exec-node-python3-script-on-ubuntu-resulting-in-errno-13-permission-denied/28021/5 "2020-06-09T18:25:46Z")

</div>

Colin, for a clean start, I exported my flows, reinstalled Node-RED in my Ubuntu machine following [https://nodered.org/docs/getting-started/raspberrypi](https://nodered.org/docs/getting-started/raspberrypi), imported flows again, and now everything works properly.  
Thank you!

---

<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:** [9 June 2020 20:17 UTC](https://discourse.nodered.org/t/exec-node-python3-script-on-ubuntu-resulting-in-errno-13-permission-denied/28021/6 "2020-06-09T20:17:13Z")

</div>

Excellent, glad to be of help.

---

<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:** [23 June 2020 20:17 UTC](https://discourse.nodered.org/t/exec-node-python3-script-on-ubuntu-resulting-in-errno-13-permission-denied/28021/7 "2020-06-23T20:17:14Z")

</div>

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