I am unable to connect to postgres DB running in container on wsl 2 from one of the service running on wsl 2.
I can connect to this DB from one another service running on wsl 2 as well as I can connect to this DB from pgAdmin running on windows and another service running on windows.
2022-02-25 20:25:52.975 INFO 2829 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2022-02-25 20:25:53.207 INFO 2829 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
But when I try to connect to this DB from another service running on wsl 2 I get
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.
I tried using WSL IP, ipv4 of system in place of localhost nothing helps. The difference between 2 services is first is uber jar and second I am trying to run using docker-compose.