"Still waiting for db to be ready... Or maybe the db is not reachable."

See original GitHub issue

API Platform version(s) affected: 2.5.7

Description
On a fresh install of API Platform package (.tar.gz), after running docker-compose up, the PHP container is trying to run the command bin/console doctrine:query:sql "SELECT 1" to see if the DB container is up and running.

The problem is that bin/console file doesn’t have the executable flag in the container, so PHP container can’t see it’s connected to DB and exited with an error.

How to reproduce

  • Download the last version in .tar.gz
  • Uncompress the directory to a location
  • Configure the DB password in docker-compose.yaml (or not, but I did it)
  • Start docker-compose (pull > up)
  • Look at the logs to see the message Still waiting for db to be ready... Or maybe the db is not reachable. x attempts left

Possible Solution
Applying +x flag to bin/console

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
BenGrandincommented, Jan 8, 2021

For me this was cause by removing apk add pdo_pgsql \ in my api/Dockerfile

I copy some of another Dockerfile, and replace this by pdo_mysql \

I search a lot on the web and found nothing, hope it can helps someone

1reaction
xavierdemoorcommented, Oct 2, 2020

Let’s do this! Do you want to work on a PR?

I started to but…

I mixed up two bugs reports for the same kind of problem. The other one was not related to api-platform but involved bin/console too.

So, here the problem is for the “Still waiting” because bin/console is not executable in some situations. It’s not because of a composer doing a cache:clear… I mixed up.

Back to this problem:

I tried different ways to install and run api-platform.

  1. Under WSL2: git clone and run => No problem on bin/console
  2. Under WSL 2: dl .tar.gz, untar, run => No problem
  3. Under Windows: dl .tar.gz on Windows, move the archive in a WSL2 dir, untar with WSL2, run => No problem
  4. Under Windows: dl .tar.gz, untar it under Windows into a WSL2 dir, run => bin/console is not executable and got the “Still waiting for db…”

I did chmod +x on bin/console under WSL2, ran docker-compose up again and the problem was solved.

So, it can’t be fixed in the Dockerfile. It’s a Windows and/or WSL2 problem only.

  • Wacuta may have done unzip/untar with Windows, lost flags, uploaded files on his VPS
  • Me, I untar the files under Windows into WSL2 dir. I don’t know how Windows do this, but it seems he doesn’t keep flags even if we untar files directly to a WSL2 dir.

The problem is because of Windows. Even with the .tar.gz file 😕

Read more comments on GitHub >

github_iconTop Results From Across the Web

Still waiting for db to be ready... Or maybe the db is not ...
No service depends_on the database, so I don't see why it would fail with that error message. But anyways, in the envvar DATABASE_URL...
Read more >
Docker Compose Wait for MySQL Container to be Ready
This article provides an example for making docker-compose wait for MySQL container to be ready before starting a dependent docker application container.
Read more >
Wait until Your Dockerized Database Is Ready before ...
In this video, we'll go over using a script to make sure your database is ready before running automated tests. Perfect for CI....
Read more >
make:docker:database - SymfonyCasts
Hello make:docker:database. Ok, ready? To manage our Docker containers, we need to create a docker-compose.yaml file ...
Read more >
Troubleshooting for Amazon RDS - AWS Documentation
Inbound rules – The access rules enforced by your local firewall and the IP addresses authorized to access your DB instance might not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found