I am taking a docker course by Stephen Grider where he sets up a Fibonacci series app that stores the index in PostgreSQL database. While calculating the value using redis. The entire thing is connected using docker-compose file. But due to some unknown issues, the API couldn't connect to the PostgreSQL and it shows the error. Any possible solution for this?
1 Answer
To my understanding, it occurs due to the time taken for resources to download and start up. On checking the logs, I found out that my server tried making connection even before postgres
database has started. And I am guessing this might have resulted in an error. So to tackle this, I ran the command twice.
The first docker-compose up --build
to download the resources. The second time to connect them. As this time, the postgres is already downloaded, I didn't face the error.
If anyone has any solution as how to make api start only after postgres has downloaded and started, do answer.
listen_addresses
is set incorrectly, or PostgreSQL is not running.