I have a play application connecting to a database at 1.2.3.4 but for some reason Play! (and other java apps too) cannot connect to it.
I did try editing the hosts file and setting a name for the IP like app01 1.2.3.4
however it only worked on the box where the DB was hosted and it didn't work for external machines. I can confirm that the right port is open in iptables and I've tried restarting it, too.
If I ping postgres at port 4567 at 1.2.3.4 from the same box, it works. But setting the same IP address in my java apps fail. What's wrong? Is it permissions or iptables issue? Thanks.
Stack trace:
Caused by: java.net.NoRouteToHostException: No route to host
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:327)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:193)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:384)
at java.net.Socket.connect(Socket.java:546)
at java.net.Socket.connect(Socket.java:495)
at java.net.Socket.<init>(Socket.java:392)
at java.net.Socket.<init>(Socket.java:206)
at org.postgresql.core.PGStream.<init>(PGStream.java:62)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:76)
... 35 more
Can you connect to your DB via pgadmin (http://www.pgadmin.org/)? Can you telnet from your machine on to the DB Server on the given port (telnet 1.2.3.4 4567)? If you cannot telnet maybe the DB Server is blocking your connections? Have you set any proxy server either only for java or only for rest of the system? From the exception it seems more of a networking issue than anything with java...