I have a service in a Docker Container, which synchronies Data from an another DB to my DB and the Sync-Container can't get a connection to the Postgres DB Container.
My Error-Message
Cannot connect to the database, exiting now: dial tcp 127.0.0.1:5432: connect: connection refused"
I can connect to the DB via TablePlus on 127.0.0.1:5432 but via Docker Inspect is
The Sync-Service is Written in Go - Database Name, User and Password are the same as I connected via TablePlus. I also tried the IPs 0.0.0.0
and the 172.19.0.2
.
Does anyone have any idea why its not connecting?
Try connecting to postgres:5432
You need to use container name when connecting from another docker container