I have a docker service for postgres that is running fine:
postgres:
restart: always
image: postgres:13.0-alpine
ports:
- "5432:5432"
environment:
- DEBUG=false
- POSTGRES_DB=yola
- POSTGRES_PASSWORD=password123
I can connect fine using terminal like this:
export PGPASSWORD=password123; psql -h localhost -p 5432 -d yola -U postgres
Now when I try and run flyway I get a connection problem.
I tried doing both 0.0.0.0
and localhost
and the docker image name yola_postgres_1
.
I still get this error running the following command:
docker run --rm -v /path/to/folder/migrations:/flyway/sql flyway/flyway -url=jdbc:postgresql://localhost:5432/yola -user=postgres -password=password123 info
ERROR: Unable to obtain connection from database (jdbc:postgresql://localhost:5432/yola) for user 'postgres': Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections. -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- SQL State : 08001 Error Code : 0 Message : Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
Caused by: org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections. Caused by: java.net.ConnectException: Connection refused (Connection refused)