title: Laravel .env DB_HOST 127.0.0.1 vs localhost
body: <p>I am confused about the <code>DB_HOST</code> variable in my Laravel environment file. Neither <code>localhost</code> or <code>127.0.0.1</code> appear to be working <em>completely</em>.</p>
  
  <p>If the host is set to <code>127.0.0.1</code>, when I attempt to run a query within Laravel it returns the error:</p>
  
  <blockquote>
    <p>SQLSTATE[HY000] [2002] Connection refused (SQL: select * from <code>users</code> where <code>email</code> = <em>email address</em> limit 1)</p>
  </blockquote>
  
  <p>Whereas, if I use <code>localhost</code>, it connects fine.</p>
  
  <p>However, when the <code>DB_HOST</code> variable is set to <code>localhost</code>, and I attempt to run  migrations or seeds, I am presented with the error:</p>
  
  <blockquote>
    <p>SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = projectmanage and table_name
       = migrations)</p>
  </blockquote>
  
  <p>Whereas, if I use DB_HOST <code>127.0.0.1</code>, it migrates/seeds fine.</p>
  
  <p>What is going on?</p>
  
  <p>I am currently working with an installation of Laravel 5.5. </p>