<p>The node.socket is a mechanism called IPC (Inter-process communication) that basically helps a CLI instance connect to the active node which is currently syncing the blockchain to your PC (local node instance).</p>
<p>Refer to <a href="https://developers.cardano.org/docs/get-started/running-cardano/" rel="nofollow noreferrer">https://developers.cardano.org/docs/get-started/running-cardano/</a> and search for &quot;--socket-path:&quot; to jump to the relevant section which tells you more about this.</p>
<p>Assuming that you aren't syncing BOTH the mainnet and testnet <strong>at the same time</strong>, you can provide the same node.socket path to the cardano-node or cardano-cli instance and things should work fine... (Experts, please correct me if this isn't how it works, as I haven't tried syncing both nets at the same time).</p>
<p>In any case, whether you sync to mainnet or testnet, the ledger data itself is downloaded to a particular path using the ----database-path option for cardano-node. As long as you specify different paths for testnet or mainnet, you should be good to go...</p>

CC BY-SA 4.0
2021-12-22T20:55:38.450Z
2021-12-22T20:55:38.450Z
Bharat Mallapur
<p>It uses the same environment variable. I've not needed to change the node socket when I switch between testnet or mainnet.</p>

CC BY-SA 4.0
2021-10-11T08:22:11.517Z
Does that mean that `carano-node`'s db directory should be the same for testnet than for mainnet?
Eric
CC BY-SA 4.0
2021-10-13T23:09:37.640Z
no, the test net is a different chain so it wouldn't use the same db as the mainnet.
jnprogrammer
CC BY-SA 4.0
2021-10-14T09:37:10.670Z
but it's ok for the node socket path to be in the same directory as the mainnet's db?
Eric
CC BY-SA 4.0
2021-10-14T13:20:13.797Z
yes, a node socket is only telling what port to use to communicate with a given node. So it can be the same port for a mainnet node and testnet node.
jnprogrammer
CC BY-SA 4.0
2021-10-14T13:21:12.963Z
When the node is running and you go to that directory where you have your node socket, you'll find its a text file that is made when you run the node.
jnprogrammer
CC BY-SA 4.0
2021-10-10T20:51:32.977Z
2021-10-10T20:51:32.977Z
jnprogrammer
<p>According to <a href="https://developers.cardano.org/docs/get-started/running-cardano#querying-the-cardano-blockchain" rel="nofollow noreferrer">the docs</a>,</p>
<blockquote>
<p>cardano-cli and other Cardano software components need to know where the node socket file is located. We saved it to the path $HOME/cardano/db/node.socket in the previous example. The components read the shell environment variable CARDANO_NODE_SOCKET_PATH to find this.</p>
</blockquote>
<p>It seems like this node socket file is specific to either the testnet or the mainnet, not both. Are you supposed to change the <code>CARDANO_NODE_SOCKET_PATH</code> environment variable every time you want to use the CLI tools with a different network?</p>

<cardano-cli>
How does the CARDANO_NODE_SOCKET_PATH environment variable work for both the mainnet and testnet?
# How does the CARDANO_NODE_SOCKET_PATH environment variable work for both the mainnet and testnet?

(Asked by: username_0 on 2021-10-10)

According to [the docs](https://developers.cardano.org/docs/get-started/running-cardano#querying-the-cardano-blockchain),

> cardano-cli and other Cardano software components need to know where the node socket file is located. We saved it to the path $HOME/cardano/db/node.socket in the previous example. The components read the shell environment variable CARDANO\_NODE\_SOCKET\_PATH to find this.

It seems like this node socket file is specific to either the testnet or the mainnet, not both. Are you supposed to change the `CARDANO_NODE_SOCKET_PATH` environment variable every time you want to use the CLI tools with a different network?

**Tags:** cardano-cli

---

## 2 answers

### Answer by username_2 on 2021-10-10. Score: 3 | Accepted answer

It uses the same environment variable. I've not needed to change the node socket when I switch between testnet or mainnet.

> **Comments:**
> **username_0**: Does that mean that `carano-node`'s db directory should be the same for testnet than for mainnet?  
> **username_2**: no, the test net is a different chain so it wouldn't use the same db as the mainnet.  
> **username_0**: but it's ok for the node socket path to be in the same directory as the mainnet's db?  
> **username_2**: yes, a node socket is only telling what port to use to communicate with a given node. So it can be the same port for a mainnet node and testnet node.  
> **username_2**: When the node is running and you go to that directory where you have your node socket, you'll find its a text file that is made when you run the node.  

---

### Answer by username_1 on 2021-12-22. Score: 0

The node.socket is a mechanism called IPC (Inter-process communication) that basically helps a CLI instance connect to the active node which is currently syncing the blockchain to your PC (local node instance).

Refer to <https://developers.cardano.org/docs/get-started/running-cardano/> and search for "--socket-path:" to jump to the relevant section which tells you more about this.

Assuming that you aren't syncing BOTH the mainnet and testnet **at the same time**, you can provide the same node.socket path to the cardano-node or cardano-cli instance and things should work fine... (Experts, please correct me if this isn't how it works, as I haven't tried syncing both nets at the same time).

In any case, whether you sync to mainnet or testnet, the ledger data itself is downloaded to a particular path using the ----database-path option for cardano-node. As long as you specify different paths for testnet or mainnet, you should be good to go...


---

