After searching for a while, didn’t find any post regarding this.

I know running node for testnet and mainnet use different configuring files, and on the cardano developer portal, they are showing the same port. But can I run both testnet and mainnet relay node on background (I assume I’d need to change the port number)? Do I need to make two different cardano-run process?

In that case, it is ok when I run cardano-cli commands just change different network, like testnet-magic ***/–mainnet? Is the rest command the same? I currently run the testnet as a systemd service, I can definitely just go ahead and run a mainnet node as another service on the background, but I want to ask before head, in case I would messed up the configurations on my server.

1 Answer 1


Yes, you would need two separate cardano-node processes, each with their own configuration and their own disk storage directory.

When using cardano-cli you will need to connect to the correct local domain socket for the network you want to connect to.

Eg for mainnet:

export CARDANO_NODE_SOCKET_PATH=/path/to/mainnet/db/node.socket
cardano-cli ....

or for testnet:

export CARDANO_NODE_SOCKET_PATH=/path/to/testnet/db/node.socket
cardano-cli ....
  • Thanks for your answer! If I do that, every time I switch between testnet and mainnet, I need to update this socket variable CARDANO_NODE_SOCKET_PATH, it there a way that it can be done automatically? I see some others suggest use two different linux accounts, it's essentially the same as changing this socket environment variable to me.
    – Cyrus
    Apr 22, 2022 at 13:48
  • You can write two trivial bash scripts, with -mainnet and -testnet in the names and setting the CARDANO_NODE_SOCKET_PATH. Apr 23, 2022 at 4:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.