我无法从WSL2上运行的服务之一连接到WSL2上容器中运行的postgres DB.
我可以从运行在WSL2上的另一个服务连接到此数据库,也可以从运行在windows上的pgAdmin和运行在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.
但是当我试图从WSL2上运行的另一个服务连接到这个数据库时,我得到了
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.
我try 使用WSL IP、ipv4系统代替本地主机,但没有任何帮助.两个服务之间的区别是第一个是uber jar,第二个是我try 使用docker compose运行.