title: AWS SQLSTATE[HY000] [2002] Connection refused
body: <p>I am new to both php and aws and I have come across an issue trying to link the aws to the simple-login php script.</p>
  
  <p>(<a href="https://github.com/panique/php-login-minimal" rel="nofollow noreferrer">https://github.com/panique/php-login-minimal</a>). </p>
  
  <p>I'm getting the following error printed:</p>
  
  <blockquote>
    <p>SQLSTATE[HY000] [2002] Connection refused</p>
  </blockquote>
  
  <p>This is my code </p>
  
  <pre><code>&lt;?php
      ob_start();
      session_start();
  
      //set timezone
      date_default_timezone_set('Europe/London');
  
      //database credentials
      define('DBHOST','instancename.cfci0i1rm4rl.us-east-2.rds.amazonaws.com');
      define('DBUSER','name_root');
      define('DBPASS','rootpassword');
      define('DBNAME','login');
  
      //application address
      define('DIR','https://union.washmel.com/user/login/auth/lr/');
      define('SITEEMAIL','noreply@domain.com');
  
      try {
  
          //create PDO connection
          $db = new PDO("mysql:host=".DBHOST.";charset=utf8mb4;dbname=".DBNAME, DBUSER, DBPASS);
          //$db-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);//Suggested to uncomment on production websites
          $db-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);//Suggested to comment on production websites
          $db-&gt;setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
  
      } catch(PDOException $e) {
          //show error
          echo '&lt;p class="bg-danger"&gt;'.$e-&gt;getMessage().'&lt;/p&gt;';
          exit;
      }
  
      //include the user class, pass in the database connection
      include('classes/user.php');
      include('classes/phpmailer/mail.php');
      $user = new User($db);
  ?&gt;
  </code></pre>
  
  <p>as follows is the link to the error on my site as it currently stands. 
  <a href="https://union.washmel.com/user/login/auth/lr/index" rel="nofollow noreferrer">https://union.washmel.com/user/login/auth/lr/index</a></p>