title: Laravel SQLSTATE[HY000] [2002] Connection refused When Command in "Controller" But Words Normally in Tinker
body: <p>So I have trying to make Autocomplete in my Project (Dictionary), and the SQL Worked normally if testing SQL Command using #Tinker.</p>
  
  <pre><code># php artisan tinker
  
  Psy Shell v0.9.9 (PHP 7.1.19 — cli)
  &gt;&gt;&gt; use App\WordsList;
  &gt;&gt;&gt; WordsList::where('Translation', 'english')-&gt;first();
  =&gt; App\WordsList {#2962
       ID: 4,
       Word: "اَلْإِنْكِلِيزِيَّة",
       SimpleWords: "الإنكليزية",
       Translation: "english",
       Views: null,
     }
  &gt;&gt;&gt; 
  </code></pre>
  
  <p>but if make that in AutoComplete Controller like this:</p>
  
  <pre><code>    public function search(Request $request) 
      {
            $search = $request-&gt;get('term');
  
            $result = WordsList::where('Translation', 'LIKE', '%'. $search. '%')-&gt;first();
  
            return response()-&gt;json($result);
  
      } 
  </code></pre>
  
  <p>Web file (Routes)</p>
  
  <pre><code>Route::get('autocomplete', 'AutoCompleteController@search');
  </code></pre>
  
  <p>if found this problem:</p>
  
  <pre class="lang-php prettyprint-override"><code>## (URL) http://127.0.0.1:8000/autocomplete/?term=english
  
  SQLSTATE[HY000] [2002] Connection refused (SQL: select * from `WordsList` where `Translation` LIKE %english% limit 1)
  </code></pre>
  
  <p><img src="https://i.imgur.com/dTYt9VG.png" alt=""></p>