Command failed: query tip Error: Error while looking up environment variable: CARDANO_NODE_SOCKET_PATH Error: "CARDANO_NODE_SOCKET_PATH"

I am trying to re-install my node using coincashew guide relay is running fine but BP is running as a relay, when I try to generate a new kes key I get the error:-

Command failed: query tip  Error: Error while looking up environment variable:      CARDANO_NODE_SOCKET_PATH  Error: "CARDANO_NODE_SOCKET_PATH"

results from running:-
ps -ef | grep cardano-node

ommited         809     734  3 08:01 ?        00:02:34 
/usr/local/bin/cardano-node run +RTS -N -A16m -qg -qb -RTS 
--topology /home/ommited/cardano-my-node/topology.json 
--database-path /home/ommited/cardano-my-node/db 
--socket-path /home/ommited/cardano-my-node/db/socket 
--host-addr --port 6000 
--config /home/ommited/cardano-my-node/config.json

ommited        5349    1214  0 09:25 pts/0    00:00:00 grep 
--color=auto cardano-node

any help would be appreciated.


if the BP is up and running, then you will must to export the socket path (update the path bellow

export CARDANO_NODE_SOCKET_PATH=/home/user/cardano/db/socket

after that login again or type source ~/.bashrc to reload the changes

error is now showing:-

cardano-cli node key-gen-KES \
    --verification-key-file kes.vkey \
    --signing-key-file kes.skey

returns to next prompt

 pushd +1
slotsPerKESPeriod=$(cat $NODE_HOME/shelley-genesis.json | jq -r '.slotsPerKESPeriod')
echo slotsPerKESPeriod: ${slotsPerKESPeriod}


pushd +1
slotsPerKESPeriod=$(cat $NODE_HOME/shelley-genesis.json | jq -r '.slotsPerKESPeriod')
echo slotsPerKESPeriod: ${slotsPerKESPeriod}
-bash: pushd: directory stack empty
slotsPerKESPeriod: 129600

check this topic for more details.

pushd and popd do not have anything to do with Cardano:

Whoever wrote whatever guide you are using used them to not have to type so much, while changing directories. If you do things in another order, the stack of directories will look different.

How easy/simple would it be to transfer to cntools?

should be very simple but after that you will need to clean, rename, move some files

cntools setup will use a different folder tree
but you already have the bins, the db, pool and wallet files, etc


Thank You.

1 Like

I have this error also

Command failed: query tip Error: Error while looking up environment variable: CARDANO_NODE_SOCKET_PATH Error: “CARDANO_NODE_SOCKET_PATH”

I have in my $HOME/.bashrc

export CARDANO_NODE_SOCKET_PATH=“/home/cardano/cardano-my-node/db/node.socket”

and in my file


do you have any advice? The typical fix seems to be at play here and the error is still there.



The node is up and running?

sudo systemctl status cardano-node

Have you loaded the changes to .bashrc using source ~/.bashrc ?

@Alexd1985 @mcrio

Thanks for your responses.


The node is up and running,

sudo systemctl status cardano-node

returns “running” (see attached image).


sudo journalctl --unit=cardano-node --follow

returns this


, so it seems to be running.

Also, I have performed source ~/.bashrc . I even did so once again just in case I had forgotten and I have the same error.

For clarity, I have a block producer node and two relays which are all running, and all returning this error when I query the node progress.

Just to make sure the environment variable is actually registered please do: printenv | grep CARDANO_NODE_SOCKET_PATH

You should not run cardano-cli with sudo. And that probably is also the error here. sudo clears the environment including the CARDANO_NODE_SOCKET_PATH variable you set.

1 Like

this returns



This is a very helpful comment, thank you. In my circumstance, when I run cardano-cli without sudo, I get this

cardano-cli: Network.Socket.connect: <socket: 11>: permission denied (Permission denied)


I think it is related to how to server is hardened. Do you have any suggestions? Much appreciated.

This looks like you are running cardano-node itself as root. Where did you get the script?

The one from does not do that. It runs cardano-node with your user (and then your user also has access to the socket).

What’s the user configured in the unit file?
cat /etc/systemd/system/cardano-node.service | grep -i user

Check file permissions of the socket file:

Yes, you are right…and I think we are honing in on the source of the trouble. Someone else prepared the server for me such that everything had to be done with sudo . For that reason, the script from coincashew would not work, so I modified it to run with sudo. This seems to be related to some of the issue here. I’m not sure why the server was set up in this way. Is there anything to be done as it is presently set up, or would I need to wipe and rebuild?


thanks, does this provide any clarity?