Can't connect to Postgres by hostname

183 views Asked by At

I've a java servlet application (java7) running on Tomcat 7 on a VM and it's Postgres 8.4 database is running on another VM. Both VMs(linux) see each other, I can ping one from another by IP and Hostname and even I can access database by PSQL command from the machine running tomcat.

Java servlet application connects to the database machine by using its IP (in connection string) perfectly fine BUT when I change it to hostname, it fails and can't connect to Postgres on that machine?

Any idea, why it happens, is it related to tomcat?

*Hostname/IP is included in /etc/hosts

0

There are 0 answers