Search code examples
anchorsolana

Connection refused trying to get account info in Solana


solana account <address>

When I get account info, I have this error:

Error: RPC request error: cluster version query failed: error sending request for url (http://localhost:8899/): error trying to connect: tcp connect error: Connection refused (os error 111)

Solution

  • The error is indicating that the CLI RpcClient can not communicate with the Solana validator.

    This is usually caused by not having solana-test-validator running in another terminal. Many make the mistake of thinking that the localhost is running the validator all the time... it's not.

    In one terminal do: solana-test-validator which will startup up the local validator Open a second terminal and do solana account - This will return account info for the default keypair