Why is there an error when accessing postgresql "User `postgres` was denied access on the database `db.public`"

Why is there an error when accessing postgresql

`User postgres` was denied access on the database `db.public`.  

My Postgresql is on local host and my nodejs Application is on container. I have set pg_hba.conf so that docker can access Postgresql. code pg_hba.conf as below.

host    all             all             172.17.0.1/16           md5
host    all             all             10.127.93.219/24     md5

I’ve also set listen_address in postgresql.conf.

listen_address='10.127.93.219'

I’ve also setup postgresql like below.

GRANT ALL ON schema public TO postgres;

But why is there this error

User `postgres` was denied access on the database `db.public`

When the error talks about a database, it’s a pure Postgres problem, has nothing to do with Docker.

Probably wrong user, pass or permissions granted on database access.

So, sending this message helps us in any way? We know it is not about docker problem. That doesn’t change the fact that we need a solution, not some annoying answers that we already know about.

Dear @alphawk, sorry you find my post not helpful. This is a Docker community forum, I am just a Docker user.

All I can tell is that the issue is not Docker related, but it is about wrong user, pass or permissions in the database. So those should be checked. If the issue persists, a PostgreSQL forum might be more helpful.

Sorry for my previous response, @bluepuma77 . I was exhausted because of this error and finding a person with the same issue was great until I see your only response.

However I fixed my issue. And issue wasn’t just about postgresql. It was about both docker and postgresql. I fixed it by setting the correct ip range on postgresql config to allow traffic from. I found the correct docker network interface and used its ip range.

Your answer has valid points though. Thank you for your kind reply.