Connection Refused

Hello,

I have finally all set with the YB Docker and able to run the container on my own. But at times, I am getting this error. However, if I retry it goes away. Do you have any idea?

ysqlsh: could not connect to server: Connection refused

  •    Is the server running on host "localhost" (127.0.0.1) and accepting*
    
  •    TCP/IP connections on port 5433?*
    

could not connect to server: Cannot assign requested address

  •    Is the server running on host "localhost" (::1) and accepting*
    
  •    TCP/IP connections on port 5433?*
    

Docker File

FROM yugabytedb/yugabyte:latest
EXPOSE 7000 9000 5433 9042
COPY startup_sh.sh /bin/
WORKDIR /home
RUN chmod +x /bin/startup_sh.sh
ENTRYPOINT ["/bin/startup_sh.sh"]

startup_sh.sh is here
#!/bin/bash
set -e
cd /bin/
yugabyted start
cd /home/yugabyte/bin/
ysqlsh -c ‘CREATE DATABASE yb_demo;’
ysqlsh -d yugabyte;

CC @dorian_yugabyte

I am so clueless and any try I did, its all failing. Yugabyte team, could you throw some idea on this?

Maybe the server isn’t running ?
Maybe you have a firewall in the middle ?
Can you check the logs of yb-tserver ?

When I hit http://127.0.0.1:7000/ OR http://127.0.0.1:9000/ I get the below error

This site can’t be reached

127.0.0.1 refused to connect.

Try:

ERR_CONNECTION_REFUSED

But when I retry, it succeeds. And when it succeeds, if I hit the above Master and T-Server, it is still the same response though

@dorian_yugabyte I tried something like this.
docker run -dit --name yugabyte yugabyte --daemon=false.
the container started and I saw an ID.

Waited for 10 to 15 seconds. And then when I run
docker exec -it yugabyte /home/yugabyte/bin/ysqlsh

it loaded the SQLSH and I was able to list down the databases, I also saw the yb_demo that I created through script. So the startup.sh takes few seconds for the YUGABYTED service to start, although the script runs quickly. How will I ensure the YUGABYTED is up ?

If I do not wait for few secs, and immediately if I issue the EXEC command mentioned above, it returns me the error below.

ysqlsh: could not connect to server: Connection refused
Is the server running on host “localhost” (127.0.0.1) and accepting
TCP/IP connections on port 5433?
could not connect to server: Cannot assign requested address
Is the server running on host “localhost” (::1) and accepting
TCP/IP connections on port 5433?

Is that the way it should be? Like I should wait for few seconds before I go to YSQLSH mode?
If thats the case, can it print a meaningful error message rather showing this up?

@dorian_yugabyte @neha @sid.choudhury

Yes, because the database is ready only after a few seconds because of yugabyted tool.

@dorian_yugabyte Ok, thats what I was assuming and now I am firm on that assumption. Thanks for the confirmation. BTW, Will you guys make any change to print a different message to show ? For example, “YugabyteD is still starting, please wait…” Something like this?

@dorian_yugabyte Also is there a way I can check whether the yugabyteD is UP and Running?

I don’t think there’s a plan to change the messaging.

How would you think to check ? Maybe you can check it yb-tserver is up and running by checking http:ip:9000 ?