Unable to connect to the database server: SQLSTATE[HY000] [2002] Connection timed out

Website URL

My website is mombaybi.com

Error Message

After some adjustments I got from Oxy senior moderator, I got to the website but now I am having Unable to connect to the database server: SQLSTATE[HY000] [2002] Connection timed out error on the content tag, other tags is working for now.

What hostname are you using in order to connect to the database?

4 Likes

Here is my hostname:

$pdo = new PDO('mysql:host=mysql;dbname=xxxxxx;charset=utf8mb4', 'xxxxxx','xxxxx', array(PDO::ATTR_TIMEOUT => 30));

You need to use the database server name, not mysql
You can find the hostname in the control panel in the MySQL Databases section.

6 Likes

thanks @Ziverre , problem solved

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.