Connect: connection refused error


Hii ,
I installed cockroachdb and started the shell , first day it opened without any problem but when i restart my computer and tried to run the shell using command cockroach sql --insecure it is appearing like this

 Welcome to the CockroachDB SQL shell.
# All statements must be terminated by a semicolon.
# To exit, type: \q.
ERROR: cannot dial server.
Is the server running?
If the server is running, check --host client-side and --advertise server-side.

dial tcp connect: connection refused
Failed running "sql"

I tried to kill the process on that port and restart the server, but no hope
but when I deleted the node and create one again it is working fine .

Why should I have to do it every time .I wonder is there any solution for this ??

Did you get an error when trying to restart the server? You shouldn’t need to delete and create node every time the server is stopped.

You can try this out by stopping and starting the server again. To stop the server:

  • If the node was started using cockroach start and is running in the foreground, press ctrl-c in the terminal.
  • If the node was started using cockroach start and the --background and --pid-file flags, run kill <pid> , where <pid> is the process ID of the node.

Thanks for the replay, No the error only appears when I restart my system . I tried to kill the process and the system couldn’t detect any process running on that port

bash: kill: (26257) - No such process

and I tried changing the port . No luck

What command did you use to start the node?

Start a Local Cluster (Insecure) | CockroachDB Docs As mentioned in this doc I used

cockroach start \
--insecure \
--store=node1 \
--listen-addr=localhost:26257 \
--http-addr=localhost:8080 \
--join=localhost:26257,localhost:26258,localhost:26259 \

this command to start the node

Running the commands described in Start a Local Cluster (Insecure) | CockroachDB Docs will start a three node local cluster that will last only until the computer is restarted. After a restart, you will need to run the three cockroach start ... commands again to have the cluster up and running. If you are already doing this - it would help to take a look at the log files and see what is there. They will be in node1,2,3 subdirectories - ./node1/logs/cockroach.log for example.

1 Like

thank you for the replay , that helped