Prestashop: Again... Link to database cannot be established: SQLSTATE[HY000] [2002] Connection timed out at line 120 in file classes/db/DbPDO.php

Created on 16 Sep 2018  路  32Comments  路  Source: PrestaShop/PrestaShop

Hi guys !

I'm using a news fresh install with 1.7.4.2. My web site use php7 and hosted at Ovh with Perf 4 (CPU : 4x vCores RAM : 8 Go) and a PrivateSql.

For this day i've had at least 15 times the classic following message => SQLSTATE[HY000] [2002] Connection timed out at line 120 in file classes/db/DbPDO.php
With written in logs => ERROR v1.7.4.2 2018/09/16 - 15:25:04: Link to database cannot be established: SQLSTATE[HY000] [2002] Connection timed out at line 120 in file classes/db/DbPDO.php

The big probleme is the error message appears database connections informations :/

Link to database cannot be established: SQLSTATE[HY000] [2002] Connection timed out
at line 120 in file classes/db/DbPDO.php

public function connect()
 {
 try {
  $this->link = $this->getPDO($this->server, $this->user, $this->password, $this->database, 5);
      } catch (PDOException $e) {
      throw new PrestaShopException('Link to database cannot be established: '.$e->getMessage());
   }

   $this->link->exec('SET SESSION sql_mode = \'\'');

   return $this->link;

    DbPDOCore->connect - [line 323 - classes/db/Db.php]
    DbCore->__construct - [line 234 - classes/db/Db.php] - [4 Arguments]

    Argument [0] cc2xxxPRIVATEINFOSxxxxx95
    Argument [1]   ch5xxxPRIVATEINFOSxxxxxgs1
    Argument [2]  ZFxxxPRIVATEINFOSxxxxxlH
    Argument [3] sexxxPRIVATEINFOSxxxxx18`

I have tried many thing but nothing seems working... I'm really desapointed and don't know what to do now...
What could i do ? Thank you so much for helping ;)

Can't Reproduce

All 32 comments

Did you ask you host about this problem?

Hi @panatan,

Your issue:[Link to DB cannot be established] => it is an error on your server, you need to check the database link.
You can the database connection information provided by your web-host in the parameters.php file into the path /Project_folder/app/config/parameters.php
Thanks to check and feedback.

Best regards, Khouloud

Hi and thank you !
The problem is that it works and sometime it doesn't... So how could i be sure that the problem comes from me host and not from Prestashop.
But i'm scary about db information shawn on the page...

Hi @panatan,

If the issue is this exact exception [Link to database cannot be established: SQLSTATE[HY000] [2002]] => your issue is not related to PrestaShop => it is an error on your server.
Also, you can increase the max_execution_time in your php.ini file.

Best regards, Khouloud

I don't think that the problem becomes not from web-host, (but i'm not sure) but it is very critical !!!

The problem comes from your web host. You must check your PrivateSql instance and everything around. It's not even a max_execution_time problem.
Try to connect to your mysql server in command line if you can :)

OK but what did i find/search ?

mysql -u MYSQL_USER -p DATABASE_NAME -h DATABASE_HOST try to connect by replacing values.
If there is a timetout, you must check if your server is able to connect to the remote PrivateSQL server.

Yes, all is good

Hi @panatan,

We need to retrieve the PHP error log and the debug mode report in order to find out what's wrong.
Don't you know how to get this information? Please read the following article:
http://build.prestashop.com/howtos/misc/how-to-create-bug-report/

Thanks!

Best regards, Khouloud

Hi Khouloud could you give me your email adress to send informations ?
Thx

Hi @panatan,

My address mail: khouloud.[email protected]

Thanks & best regards, Khouloud

Informations had been send by email, please let me know if you need other elements
Best regards

Hi @panatan,

Sorry, I did not receive any mail from you.
Thanks to check again.

Best regards, KHouloud

Mmm strange thing, well i send again just now, it came from chrgilles[at]gmail.com

Hi @panatan,

Sorry no.
Could you please try with this khouloud-belguith.[email protected]

Best regards, Khouloud

And send again now ;)

Hi @panatan,

Sorry No.
I checked sending & receiving emails into my account => it's ok.
You have a problem from your side.

Best regards, Khouloud

Well no chance since few days for me :/
Will try again soon

And again from an other email hosting

khouloud-belguith.[email protected] comes in error :/

@panatan,

You can try with khouloud.[email protected], there's no problem

Done with an other host please let me know if it's good now

Hi @panatan,

Could you please provide me your address mail to contact you.

Best regards, Khouloud

yes here it is => chrgilles[at]gmail.com

@panatan Done.

Ok good reception => elements has been send...
掳_掳

Hi @panatan,

I just received the email.
I will check & feedback.

Best regards, Khouloud

Great ! Super !

Hi @panatan,

As I said before, it is a server issue.
Link to database cannot be established: SQLSTATE[HY000] [2002] Connection timed out
You should ask your provider for the correct data to put there. There are several possible methods to connect to database, only your provider knows how he configured his server.

Best regards, Khouloud

Hi, the problem is that it works fine but several times it is immedialelty broken (so no time out), and when it's broken it shows db informations...

Hi @panatan,

It seems that your issue is not a PrestaShop's core bug but most likely a server configuration or customization problem.

Best regards, Khouloud

Was this page helpful?
0 / 5 - 0 ratings