Randomly, I get the following error while updating my system:
Fatal error: Uncaught PDOException: SQLSTATE[HY000] [2002] Cannot assign requested address
By mistake, it can not connect to the server, but the server is there, and it's on, of course, because on other PC's when it does this error in mine,
There is no standard for this to happen, it's for no reason, sometimes when I update my page, or I make a request via ajax, PHP returns me this error, you do not have to do anything, just update one or two (sometimes much more) that it goes back to working normally.
Detail, this occurs more often on my production PC (with ubuntu 16.4), in my test (Win 7) it rarely occurs.
This system is on an internal server (Debian 7), the network has proxy and firewall, but my development PCs do not go through either.
I'm already having this annoying problem for a few days, any suggestions are welcome as I've tried everything I could think of.
NOTE: My database is relatively large.
The connection code is as basic as possible:
namespace MySQL;
class MySQLConector {
/**
* Receber a conexão
* @return \PDO
*/
public static function get_conn() {
$database_url = '192.168.0.254';
$database = 'database';
$database_user = 'user';
$database_pass = 'password';
$PDO = new \PDO('mysql:host=' . $database_url . ';dbname=' . $database . '', $database_user, $database_pass);
$PDO->exec("SET NAMES UTF8");
//$PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $PDO;
}
}