title: Connection Attempt Failed, Connected Party didn't Properly Respond
body: <blockquote>
    <p>SQLSTATE[HY000] [2002] A connection attempt failed because the
    connected party did not properly respond after a period of time, or
    established connection failed because connected host has failed to
    respond. (SQL: SELECT * FROM users)</p>
  </blockquote>
  
  <p>I want to connect to my remote database in my local project but when I do I get the error listed above. It works in my another database (from localhost), how can I connect my remote server database?</p>
  
  <p><strong>database.php</strong> </p>
  
  <pre><code>'mysql2' =&gt; [
      'driver' =&gt; 'mysql',
      'host' =&gt; 'domain.com',
      'port' =&gt; '3306',
      'database' =&gt; 'mybd',
      'username' =&gt; 'username',
      'password' =&gt; 'password',
      'charset' =&gt; 'utf8mb4',
      'collation' =&gt; 'utf8mb4_unicode_ci',
      'prefix' =&gt; '',
      'options' =&gt; ['mode' =&gt; 'ssl'],
      'strict' =&gt; false,
      'engine' =&gt; null,
  ]
  </code></pre>
  
  <p><strong>Controller</strong> </p>
  
  <pre><code>public function test()
  {
      $users = DB::connection('mysql2')-&gt;select("SELECT * FROM users");
      dd($users);
  }
  </code></pre>