title: Laravel Microsoft Sql Server connection error
body: <p>I get the following error and I don't know why:</p>
  
  <blockquote>
    <p>Illuminate \ Database \ QueryException (08001)  SQLSTATE[08001]: [Microsoft][ODBC Driver 13 for SQL Server]TCP Provider: No connection could be made because the target machine actively refused it.</p>
  </blockquote>
  
  <p><strong>.env</strong> contains</p>
  
  <pre><code>DB_CONNECTION=sqlsrv
  DB_HOST=server\name
  DB_PORT=1433
  DB_DATABASE=mydatabasename
  DB_USERNAME=dbusername
  DB_PASSWORD=dbuserpassword
  </code></pre>
  
  <p><strong>database.php</strong></p>
  
  <pre><code>'default' =&gt; env('DB_CONNECTION', 'sqlsrv'), 
      'connections' =&gt; [ 
      'sqlsrv' =&gt; [
              'driver' =&gt; 'sqlsrv',
              'host' =&gt; env('DB_HOST', 'server\name'),
              'port' =&gt; env('DB_PORT', '1433'),
              'database' =&gt; env('DB_DATABASE', 'mydatabasename'),
              'username' =&gt; env('DB_USERNAME', 'dbusername'),
              'password' =&gt; env('DB_PASSWORD', 'dbuserpassword'),
              'charset' =&gt; 'utf8',
              'prefix' =&gt; '',
              'pooling' =&gt; false,
          ],
  
      ],
  </code></pre>
  
  <p>The error is thrown in the UserController.php on this line in the submitLogin function:</p>
  
  <pre><code>if (Auth::attempt(['user_name'=&gt;$request['user_name'], 'password'=&gt;$request['password']])) {
              return redirect()-&gt;route('dashboard');
          }
  </code></pre>
  
  <p>and the User Model has these fields defined:</p>
  
  <pre><code>public $timestamps = false;
  protected $table = 'USERS';
  protected $primaryKey = 'USER_ID';
  </code></pre>
  
  <p>Also:
  I am using php 7.0.23, wamp64bit 3.1.0
  with extensions:</p>
  
  <pre><code>extension=php_sqlsrv_7_ts_x86.dll
  extension=php_sqlsrv_7_ts_x64.dll
  
  extension=php_sqlsrv_7_nts_x86.dll
  extension=php_sqlsrv_7_nts_x64.dll
  
  extension=php_pdo_sqlsrv_7_ts_x86.dll
  extension=php_pdo_sqlsrv_7_ts_x64.dll
  
  extension=php_pdo_sqlsrv_7_nts_x86.dll
  extension=php_pdo_sqlsrv_7_nts_x64.dll
  </code></pre>
  
  <p>enabled
  <a href="https://i.stack.imgur.com/cijzO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cijzO.png" alt="enter image description here"></a></p>
  
  <p><strong>I should also note that the database is pre existing.</strong></p>
  
  <p>What can I do or change or fix to get the connection to the server established without error?</p>