title: PHP Connection Refused (HY000/2002) on LocalHost
body: <p>After reading over a number of the similar topics here and on other various internet forums, I'm still having an issue with my PHP code which is throwing me for a loop... Here's the error that the <code>error_log</code> file is giving me:</p>
  
  <pre><code>[30-Apr-2018 17:05:11 UTC] PHP Warning:  mysqli::mysqli(): (HY000/2002): Connection refused in /home/nicktric/public_html/index.php on line 12
  </code></pre>
  
  <p>And here is the current, and very simple, state of my code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
  
  &lt;?php
  $servername = "127.0.0.1";
  $username = "nicktric_admin";
  $password = "########";
  $dbname = "nicktric_routes";
  
  // Create connection
  $conn = new mysqli($servername, $username, $password, $dbname);
  // Check connection
  if ($conn-&gt;connect_error) {
      die("Connection failed: " . $conn-&gt;connect_error);
  } 
  
  $sql = "SELECT name, server, status FROM routeStatus";
  $result = $conn-&gt;query($sql);
  
  if ($result-&gt;num_rows &gt; 0) {
      // output data of each row
      while($row = $result-&gt;fetch_assoc()) {
          echo "&lt;br&gt; id: ". $row["name"]. " - Name: ". $row["server"]. " " . $row["status"] . "&lt;br&gt;";
      }
  } else {
      echo "0 results";
  }
  
  $conn-&gt;close();
  ?&gt; 
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I've tried the following so far:</p>
  
  <ul>
  <li>Changing hostname between <code>localhost</code>, <code>127.0.0.1</code>, and the server shared IP</li>
  <li>Modifying the PHP socket to no avail, as I was unable to find the proper configuration to do so on CPanel</li>
  </ul>
  
  <p>Additionally, some things to note are:</p>
  
  <ul>
  <li>I am doing this off of CPanel web hosting</li>
  <li>The database name, username, and password are all correct and linked to the database (Password covered for security)</li>
  </ul>