title: PHP PDO SQLSTATE[HY000] [2002] Connection refused
body: <p>So situation is this , on localhost all seems working (mamp pro) and there are no issues at all , but when i upload it to a server it gives me an error :</p>
  
  <pre><code>SQLSTATE[HY000] [2002] Connection refused
  </code></pre>
  
  <p>Don't really know what this means, searched around on net but found no solution.
  here is how i'm making the connection to database:</p>
  
  <pre><code>define("SERVER_SQL_VERSION","mysql");
  define("SQL_SERVER","localhost");
  define("SQL_PORT","3306");
  define("SQL_USERNAME","userdb_new");
  define("SQL_PASSWORD","92384923jjdhasj");
  define("SQL_DB_NAME","usernew_db");
  define('PREFIX', 'tb_');
  if(!function_exists('pdoConnect')) {
  function pdoConnect() {
      $pdo = new        PDO(SERVER_SQL_VERSION.":host=".SQL_SERVER.";dbname=".SQL_DB_NAME."",   "".SQL_USERNAME."", "".SQL_PASSWORD.""); 
      $pdo-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
      $pdo-&gt;setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
      return $pdo;
  }
  }
  $db = pdoConnect();
  </code></pre>
  
  <p>Any help regarding this would be appreciated, Thanks.</p>