Perhaps your app tries to use a dns server first to find the IP of the database server. Take a look at your /etc/host.conf and change
to
to use your /etc/hosts file before a dns server.
Also add an entry in /etc/hosts for your database server if not already exists.