title: Web application unable to connect to Postgres database on virtual machine
body: <p>I have created a web application in Java and hosted it on a VM. It is getting hosted as I can see the start page of web application. But the problem arises when the hosted web application tries to connect to the Postgres database.</p>
  
  <p>This web application is properly getting connected on the local host if I use the following connection string for JDBC:</p>
  
  <pre><code>DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgres",
              "postgres", "password");
  </code></pre>
  
  <p>But when hosted on VM it is not getting connected. I tried everything from other stackoverflow thread like <a href="https://stackoverflow.com/questions/1287067/unable-to-connect-postgresql-to-remote-database-using-pgadmin">this</a> to change the configuration files of Postgres in VM but still it is not working.</p>
  
  <p><strong>Note</strong>: Postgres is also running on VM.</p>
  
  <p>I have converted my web application from local host to <code>.war</code> file and deployed this file on the VM.</p>
  
  <p>Can anyone tell if I have to do any other additional settings in order for the hosted web application to query the database in the VM?</p>