Cannot connect to YugaByte


I have a Go application that uses YugaByte and I have some tests for the same. While I run the tests in the pipeline and try to connect to yugabyte, it says connection refused.

Here is a snippet from my workflow file:

        image: yugabytedb/yugabyte:
          - 2021:7000
          - 2022:9000
          - 2023:5433
          - 2024:9042

Locally, I use the following command to run the container:

docker run  -d -p2021:7000 -p2022:9000 -p2023:5433 -p2024:9042 -v ~/yb_data:/home/yugabyte/var yugabytedb/yugabyte:latest bin/yugabyted start --daemon=false

I am not sure how I can specify these docker commands in the workflow file.

Thank You

Hi @mithali-zs,

Glad to see you in Github Commnity Forum!

The code works fine on my workflow. Could it be possible that the connection refused caused by the network issue? Please try again with Github hosted runner.

If the issue persists, could you please share a sample repo/workflow yaml for further investigation?

Please check github docker services doc and sample workflows below, hope it helps.

Hi @weide-zhou.

Thanks for your reply.

When I tried it out, the service container was up and running. But I am not able to connect to it in my code.

What I have noticed even on my local is that in order for me to create a cluster successfully, bin/yugabyted start --daemon=false needs to be specified in docker run, else the container stops and you don’t see it when you do docker ps.

Here is the link to the documentation I referred to :

Is there a way for me to provide this in workflow file?

Hi @mithali-zs,

This should be due to the service is not alive during workflow, hence you cannot connect it.
Typically we can add a simple healthcheck to keep the service alive, and then you can connect it and run your docker command in the workflow step.
Please refer to the answer here for more details.

BTW, there is an action ‘yugabyte/yugabyte-db-action@master’ which can help to set up a YugabyteDB database, does it meet your requirements?

- name: Setup YugabyteDB cluster
  uses: yugabyte/yugabyte-db-action@master
    yb_master_ui_port: 7000
    yb_tserver_ui_port: 9000    
    ysql_port: 5433
    ycql_port: 9042


Hi @weide-zhou,

Thank you for your help. :slight_smile:
As you suggested, I tried to add a healthcheck to keep the service alive. That did not work. It said yugabyte was unhealthy.

However, ‘yugabyte/yugabyte-db-action@master ’ works fine. But there is an issue here. This creates a docker container and it does not stop even after the pipeline ends. So when I re run the pipeline, it fails at Setup YugabyteDB cluster as it complains that the port is already being used.

Is there a cleaner way to do this?

Thank You

Hi @mithali-zs,

when I re run the pipeline, it fails at Setup YugabyteDB cluster as it complains that the port is already being used.

Looks you are using self-hosted runner since hosted runner will be discarded after workflow complete.
In this case, at the end of the job, you can manually turnoff the container, it will release the ports as well.


Thanks for your help @weide-zhou :slight_smile: