0

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?

enter image description here

6
  • That is either a network problem, or listen_addresses is set incorrectly, or PostgreSQL is not running. Commented Jul 12, 2023 at 5:53
  • Hey. I have answered the question. Kindly go through it.
    – Sandeep M
    Commented Jul 13, 2023 at 3:25
  • Does this answer your question? Docker wait for postgresql to be running
    – Phil
    Commented Jul 13, 2023 at 5:16
  • Your answer shows that PostgreSQL was not started. Commented Jul 13, 2023 at 6:17
  • Yes. It took some time to start after downloading. But the next time it started directly.
    – Sandeep M
    Commented Jul 14, 2023 at 3:41

1 Answer 1

-1

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.