Sui client: Connection refused

If a sui client sub-command returns a Connection refused response for a response you expected to go to devnet:

Networking or low-level protocol error: HTTP error: error trying to connect: tcp connect error: Connection refused (os error 111)

Double check that your client is pointing to devnet using:

$ sui client envs
localnet => http://0.0.0.0:9000 (active)
devnet => https://fullnode.devnet.sui.io:443

If as in the output above, your call indicates that localnet is active, it means that your request was sent to your locally running network (which will fail if it is not actually running). To switch to devnet, use:

$ sui client switch --env devnet
13 Likes

good thank you very :smiling_face: :smiling_face: :smiling_face: :smiling_face:

7 Likes

The error also happens happens for me trying to create a local environment after updating the sui client, yet switching to devnet doesn’t help.

sui client new-env --alias local --rpc https://127.0.0.1:9000 

as shown in the sui docs (guides/developer/getting-started/local-network). Switching to devnet doesn’t change anything.

I just updated my sui client before to be up-to-date with the latest devnet version with:

cargo install --locked --git https://github.com/MystenLabs/sui.git --branch devnet sui

, running sui-client 1.25.0-b10ea7331e1c now

Is there something I am missing?

Full Error:

Networking or low-level protocol error: HTTP error: error trying to connect: tcp connect error: Connection refused (os error 61)

Caused by:
    HTTP error: error trying to connect: tcp connect error: Connection refused (os error 61)

Hi @gordonkoehn,

One thing I noticed from your call to sui client new-env is that you are setting up your local network to use HTTPS which should not be necessary (and probably will not work), the local environment should be set-up like this:

sui client new-env --alias local --rpc http://127.0.0.1:9000 

(no HTTPS)

If that doesn’t fix your issue I’ll need some more details to figure out what’s going on, such as a full list of repro instructions (to confirm that you are running a local network that can be connected to).

Yes, I tried both “http” and "“https”, my apologies for writing the “https” not according to the tutorial.

This is my current environmental setup:

What else do you need me to provide? Where do I find the repro instructions?

Hi @gordonkoehn,

The issue is that the CLI will try and check that the RPC is reachable before adding it, so you will need to be running the local network before you add the environment. Can you confirm that you are running a local instance of the network while running these commands? It would be started using something like sui start (running in another terminal).

1 Like

Hi @amnn
Thank you. Indeed, it appears no local instance was running.
Yet the sui start failed with the below error message:

Cannot run genesis with non-empty Sui config directory ~/.sui/sui_config, please use the --force/-f option to remove the existing configuration

I deleted my sui config and started fresh. Now it works.

Do you know why this happened?

Thanks, Gordon

Hi @gordonkoehn,

This happens if you have previously run sui genesis and created a configuration for a local network. It sounds like you are running something like the following to start your network:

$ sui genesis
$ sui start

Is that right? If so, it’s the sui genesis command that is complaining, because it will overwrite your previous configuration. You can run the following to force regenerating the configuration:

$ sui genesis -f

(This is similar to deleting the sui_config directory)

Or you can run sui start resuming the configuration you had created previously with:

$ sui start

If you had already run a local network before, this will pick back up where it left off (all the objects and package you previously created will still be there).

1 Like

Fantastic, thank you for the comprehensive explanation. Works all now!