<ol>
<li>Stop using root (for interactive as well as systemd startup user), it's a terrible idea to run applications</li>
<li>You cannot (*should not) run something as another user and point to paths in your own $HOME folder, this will more often than not only lead you to permission errors.</li>
<li>I assume <code>node.socket=</code> was a typo, if not - your start command does not match $CARDANO_NODE_SOCKET_PATH environment variable.</li>
</ol>
<p>While you can now address the state by recursively fixing permissions, you've likely populated environment variables, build caches, profiles, etc across a mix of <code>root</code> and <code>toby</code> user, you might want to start from scratch and not run anything to do with cardano-node.</p>

CC BY-SA 4.0
2022-06-27T10:46:37.947Z
0. Thanks for the reply! 

1. Okay, I am no linux expert:) I just followed some tutorial online, however I saw that there were some cardano tutorials that created an own user for cardano node. I will look into that.

2. Noted.

3. This was actually not a typo. I found this a bit weird, because I could not recall the socket filename had an = when running command line directly. However, now I don't understand why I do not get a "cannot find socket" error instead... My $CARDANO_NODE_SOCKET_PATH points to a file without the =
tobben24
CC BY-SA 4.0
2022-06-28T05:40:16.893Z
If there are online tutorials using root, I think it's potentially good to highlight bad practices to them (if they've a way to contact on their pages).

About 3, if it wasnt a typo, then perhaps one of your earlier attempts to run `cardano-node` may have accidentally had an `=` sign after socket. Once you stop all instances of node running, you should be alright
RdLrT
CC BY-SA 4.0
2022-06-30T07:51:28.387Z
Okay, I will try to delete the db folder and have a new go for scratch. Thanks for the input @RdLrT!
tobben24
CC BY-SA 4.0
2022-06-27T09:41:15.573Z
2022-06-27T09:41:15.573Z
RdLrT
<p>I've successfully setup and running cardano node from terminal. Now I've setup cardano node to run as service(systemd, Ubuntu) so that I don't have to run the command all the time and have a terminal always open. From journalctl log all looks good, and I have check tip is reached using explorer.cardano.org. However, I now get error when using cardano-cli and I cannot figure out why...</p>
<p><strong>Details</strong></p>
<p><em>Cardano-cli error message</em></p>
<p>Network.Socket.connect: &lt;socket: 11&gt;: permission denied (Permission denied)</p>
<p><em>ls command</em></p>
<ul>
<li>srwxr-xr-x 1 root root      0 juni  26 23:45 node.socket=</li>
</ul>
<p><em>.service file</em></p>
<p>[Unit]
Description=Runs cardano-node mainnet
After=network-online.target
StartLimitIntervalSec=0</p>
<p>[Service]
Type=simple
Restart=always
RuntimeMaxSec=432000
User=root
ExecStart=/home/toby/cardano-scripts/run-cnode-main.sh</p>
<p>[Install]
WantedBy=multi-user.target</p>
<p><em>run-cnode-main.sh</em></p>
<p>#!/bin/bash
#Start cardano-node on mainnet
/home/toby/.local/bin/cardano-node run --config /home/toby/cardano-main/mainnet-config.json --database-path /home/toby/cardano-main/db/ --socket-path /home/toby/cardano-main/db/node.socket --host-addr 127.0.0.1 --port 1337 --topology /home/toby/cardano-main/mainnet-topology.json</p>

<cardano-node>
Socket permission denied when running cardano node as linux service
# Socket permission denied when running cardano node as linux service

(Asked by: username_0 on 2022-06-27)

I've successfully setup and running cardano node from terminal. Now I've setup cardano node to run as service(systemd, Ubuntu) so that I don't have to run the command all the time and have a terminal always open. From journalctl log all looks good, and I have check tip is reached using explorer.cardano.org. However, I now get error when using cardano-cli and I cannot figure out why...

**Details**

*Cardano-cli error message*

Network.Socket.connect: : permission denied (Permission denied)

*ls command*

* srwxr-xr-x 1 root root 0 juni 26 23:45 node.socket=

*.service file*

[Unit]
Description=Runs cardano-node mainnet
After=network-online.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RuntimeMaxSec=432000
User=root
ExecStart=/home/toby/cardano-scripts/run-cnode-main.sh

[Install]
WantedBy=multi-user.target

*run-cnode-main.sh*

#!/bin/bash
#Start cardano-node on mainnet
/home/toby/.local/bin/cardano-node run --config /home/toby/cardano-main/mainnet-config.json --database-path /home/toby/cardano-main/db/ --socket-path /home/toby/cardano-main/db/node.socket --host-addr 127.0.0.1 --port 1337 --topology /home/toby/cardano-main/mainnet-topology.json

**Tags:** cardano-node

---

## 1 answers

### Answer by username_1 on 2022-06-27. Score: 1

1. Stop using root (for interactive as well as systemd startup user), it's a terrible idea to run applications
2. You cannot (\*should not) run something as another user and point to paths in your own $HOME folder, this will more often than not only lead you to permission errors.
3. I assume `node.socket=` was a typo, if not - your start command does not match $CARDANO\_NODE\_SOCKET\_PATH environment variable.

While you can now address the state by recursively fixing permissions, you've likely populated environment variables, build caches, profiles, etc across a mix of `root` and `toby` user, you might want to start from scratch and not run anything to do with cardano-node.

> **Comments:**
> **username_0**: 0. Thanks for the reply!   1. Okay, I am no linux expert:) I just followed some tutorial online, however I saw that there were some cardano tutorials that created an own user for cardano node. I will look into that.  2. Noted.  3. This was actually not a typo. I found this a bit weird, because I could not recall the socket filename had an = when running command line directly. However, now I don't understand why I do not get a "cannot find socket" error instead... My $CARDANO_NODE_SOCKET_PATH points to a file without the =  
> **username_1**: If there are online tutorials using root, I think it's potentially good to highlight bad practices to them (if they've a way to contact on their pages).  About 3, if it wasnt a typo, then perhaps one of your earlier attempts to run `cardano-node` may have accidentally had an `=` sign after socket. Once you stop all instances of node running, you should be alright  
> **username_0**: Okay, I will try to delete the db folder and have a new go for scratch. Thanks for the input @RdLrT!  

---

