title: Connect Script PHP in external DB
body: <p>I have a PHP script that I'm trying to connect to an external database to which I have access as a user, I have the IP and port of the same. But when trying to connect via mysqli it gives me the following error:</p>
  <blockquote>
  <p>Error: Failed to connect to MySQL: 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.</p>
  </blockquote>
  <p>Has anyone experienced this and know how to resolve it? I've already seen several data in nothing and forums and I haven't found it.</p>
  <p>Code to validate the connection:</p>
  <p>PS: Is a SQL Server DB</p>
  <pre><code>$mysqli = new mysqli(&quot;Server IP&quot;,&quot;UserName&quot;,&quot;Password&quot;,&quot;DB Name&quot;,Port);
  
  // Check connection
  if ($mysqli -&gt; connect_errno) {
    echo &quot;Failed to connect to MySQL: &quot; . $mysqli -&gt; connect_error;
    exit();
  }
  ?&gt;
  </code></pre>