1

Error:

SQLSTATE[HY000] [2002] Connection refused

Connect code:

$sqlserverhost = "185.34.52.195";
$sqlserveruser = "cl";
$sqlserverdb = "cl";
$sqlserverpass = "hidden";


try {
    $dbs = new PDO("mysql:host=$sqlserverhost;dbname=$sqlserverdb;port=3306;", $sqlserveruser, $sqlserverpass);
} catch (PDOException $e) {
    print "Klaida Nepavyko prisijungti prie serverio duomenu bazes: " . $e->getMessage() . "<br/>";
    die();
}

I can connect with user/password to phpMyAdmin. Port is right:

tcp   0   0 127.0.0.1:3306   0.0.0.0:*   LISTEN   694/mysqld

What I can do to solve this problem? This problem was solved by changing port, but my port is right.

Community
  • 1
  • 1
PovilasC
  • 123
  • 9
  • Possible duplicate of [PHP Connection failed: SQLSTATE\[HY000\] \[2002\] Connection refused](http://stackoverflow.com/questions/29395452/php-connection-failed-sqlstatehy000-2002-connection-refused) – Gaurav Rai Feb 25 '16 at 10:44
  • I did not found solution there @GauravRai – PovilasC Feb 25 '16 at 10:44
  • Is the mysql on a remote server? If yes, then are you allowed to connect to it remotely? This is unlikely to be a programming issue, this is most liekly an issue with computer operations. – Shadow Feb 25 '16 at 11:11
  • Yes, mysql is on remote server. How can I allow it? – PovilasC Feb 25 '16 at 11:12
  • But, i can connect to phpMyAdmin from remote PC (server is on linux) :/ – PovilasC Feb 25 '16 at 11:15
  • Have you solved the issue?.I'm having the same problem.please post the answer if you solved it – Geethu Oct 24 '17 at 08:10

0 Answers0