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 0.0.0.0 --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.

hello,

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:-

cd $NODE_HOME
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}

returns:-

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: https://opensource.com/article/19/8/navigating-bash-shell-pushd-popd

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

cheers,

Thank You.

1 Like

Hello,
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 startCardanoNode.sh file

SOCKET_PATH=/home/cardano/cardano-my-node/db/node.socket

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

Thanks.

Hi,

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.

image

The node is up and running,

sudo systemctl status cardano-node

returns “running” (see attached image).

Also,

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

returns this

image

, 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

CARDANO_NODE_SOCKET_PATH=/home/cardano/cardano-my-node/db/node.socket

image

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)

image

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 startCardanoNode.sh script?

The one from https://www.coincashew.com/coins/overview-ada/guide-how-to-build-a-haskell-stakepool-node/part-ii-configuration/creating-startup-scripts 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:
ls -l $CARDANO_NODE_SOCKET_PATH

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 startCardanoNode.sh 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?

image

thanks, does this provide any clarity?