So, I’m trying to setup the database that’s running on a container, when I run mix ecto.setup I started to receiving this error
** (Mix) The database for Api.Repo couldn't be created: connection not available and request was dropped from queue after 2000ms. This means requests are coming in and your connection pool cannot serve them fast enough. You can address this by:
1. Ensuring your database is available and that you can connect to it
2. Tracking down slow queries and making sure they are running fast enough
3. Increasing the pool_size (although this increases resource consumption)
4. Allowing requests to wait longer by increasing :queue_target and :queue_interval
See DBConnection.start_link/2 for more information
I had tried all the points addressed by the message and all the solutions that I found searching about this error.
The strangest part is that yesterday I run all ecto commands and they all was succeeds and today when I tried to runned a simple migration command I started to receive this error, and I don’t edited none configuration file.
I suggest checking docker container logs for warning or errors. Most likely either that is either network configuration issue or database. At least I do no see matching database name “api_dev” in container configuration. Ensure that database is available on localhost:5432.
If you’re not trying to access it in the exact same way that mix would be attempting to access it (from local, from inside container, etc), then you’re going to be stuck. Another option would be to run iex and try to connect to postgresql from there. I’d try to do either of those as your next debug step.
I tried to run inside iex but I receive [error] Postgrex.Protocol (#PID<0.495.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (localhost:5432): timeout, I’m using the same parameters to connect throu
Hmmm…now you’re just going to have to guess. It is a timeout, so it looks like iex isn’t seeing the port being open at all. Could be that localhost isn’t translating properly? Maybe try 127.0.0.1 instead?
Highly unlikely that Docker is broken. You either didn’t specify a host name or Docker is listening on another IP address as @tj0 said. Pretty sure your scenario is super easy to handle, shame that you gave up.
My Postgres is running on 5432 and docker as well, the hostname it’s localhost, and I noticed that some colegues is getting the same error using a totally different docker-compose.yml or simply by running the Postgres container that docker desktop give us.
I runned another test, I take a fresh new MacBook Pro, installed the docker and executed the Postgres container, and worked, so probably is some bad config on my docker that is causing this