MySQL database troubleshooting

Customers utilising MySQL for their website backend can experience errors with connection to the database server if their application is not configured to connect to the correct MySQL server. This support page will list possible errors customers may get on their websites and possible causes and resolutions for those errors.

Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'localhost'

If you are subscribed to a Cloud Hosting plan, "localhost" is not the MySQL server hostname. Customers usually get this error when they are migrating their website to us from another provider. Check whether or not you have done the following:

If everything is set correctly, but you're still getting an error - please contact our support team for further assistance.

User has exceeded the max_user_connections resource

Our Cloud Hosting MySQL servers have a "20 concurrent connections" limit per MySQL user to prevent heavy MySQL load on the server and to identify scripts that use unnecessary MySQL connections due to bad coding practices. These errors can be prevented by making some tweaks in the code of the website:

  • Use mysql_connect() for connections to MySQL databases in your code. The advantage is the link to the server will be closed as soon as the execution of the script ends, unless it's closed earlier by explicitly calling mysql_close(). A detailed explanation can be found at
  • Use of mysql_close() explicitly. Although mysql_connect() closes the connections, use of mysql_close() in conjunction with it would make sure that the connection is definitely closed
  • Prevent use of mysql_pconnect(). "pconnect" means "Persistent Connection", i.e. the connection to the MySQL server will not be closed when the execution of the script ends. Do not attempt to use it in clustered environments.
    Note: mysql_close() will not close links established by mysql_pconnect.