are you sure the database server as same as the web server?
in some hosting providers (such as the cloud hostings) the database server is deferent by the web server.
is those cases you most replace the database server address or ip with the default localhost value.
i hope this instruction help you to solving problem