Skip to content

Cannot connect to cassandra db from my application #26047

Answered by dakale
vivekab asked this question in Actions
Discussion options

You must be logged in to vote

This is a common problem thats caused by trying to access the service (cassandra) before it is fully online and ready to handle connections. This is more a matter of how docker works when starting containers in the background, its async. We can add a simple healthcheck so that the rest of the steps downstream dont run until the service is healthy (if the container doesnt have any good tools in it for performing a healthcheck, you could always just sleep 30 on the host as a step, for eg)

Heres a quick sample I wrote:

on:
  push:
    paths:
    - .github/workflows/cassandra.yaml

jobs:
test:
runs-on: ubuntu-latest
services:
cassandra:
image: cassandra
ports:
- 9042:9042
options: --health-cmd…

Replies: 7 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants