title: Laravel: Access denied for user 'forge'@'localhost' (but no such user is used in the app)
body: <p>I've a Laravel application that works well but for some strange reason there is a lot of strange messages in log files:</p>
  
  <blockquote>
    <p>[2019-10-04 10:24:21] production.ERROR: SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: NO) {"exception":"[object] (Doctrine\DBAL\Driver\PDOException(code: 1045): SQLSTATE[HY000] [1045] Access d     enied for user 'forge'@'localhost' (using password: NO) at /var/www/html/pzw_prod/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:31, PDOException(code: 1045): SQLSTATE[HY000] [1045] Access denied for user 'forge'@'l     ocalhost' (using password: NO) at /var/www/html/pzw_prod/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:27)</p>
  </blockquote>
  
  <p>The thing is, I'm not connecting to database with user named <code>forge</code>. My <code>.env</code> uses completely different logins. And, I repeat, everything works fine: communication with database works as expected. Data is being successfully read and written.</p>
  
  <p>So... why this message in log files?</p>
  
  <p>UPDATE:</p>
  
  <p><code>config('database')</code></p>
  
  <pre><code>$ php artisan tinker
  Psy Shell v0.9.9 (PHP 7.2.22 — cli) by Justin Hileman
  &gt;&gt;&gt; config('database')
  =&gt; [
       "default" =&gt; "mysql",
       "connections" =&gt; [
         "sqlite" =&gt; [
           "driver" =&gt; "sqlite",
           "url" =&gt; null,
           "database" =&gt; /* CENSORED */,
           "prefix" =&gt; "",
           "foreign_key_constraints" =&gt; true,
         ],
         "mysql" =&gt; [
           "driver" =&gt; "mysql",
           "url" =&gt; null,
           "host" =&gt; "127.0.0.1",
           "port" =&gt; "3306",
           "database" =&gt; /* CENSORED */,
           "username" =&gt; "prod_pzw",
           "password" =&gt; /* CENSORED */,
           "unix_socket" =&gt; "",
           "charset" =&gt; "utf8",
           "collation" =&gt; "utf8_unicode_ci",
           "prefix" =&gt; "",
           "prefix_indexes" =&gt; true,
           "strict" =&gt; true,
           "engine" =&gt; null,
           "options" =&gt; [],
         ],
         "pgsql" =&gt; [
           "driver" =&gt; "pgsql",
           "url" =&gt; null,
           "host" =&gt; "127.0.0.1",
           "port" =&gt; "3306",
           "database" =&gt; /* CENSORED */,
           "username" =&gt; "prod_pzw",
           "password" =&gt; /* CENSORED */,
           "charset" =&gt; "utf8",
           "prefix" =&gt; "",
           "prefix_indexes" =&gt; true,
           "schema" =&gt; "public",
           "sslmode" =&gt; "prefer",
         ],
         "sqlsrv" =&gt; [
           "driver" =&gt; "sqlsrv",
           "url" =&gt; null,
           "host" =&gt; "127.0.0.1",
           "port" =&gt; "3306",
           "database" =&gt; /* CENSORED */,
           "username" =&gt; "prod_pzw",
           "password" =&gt; /* CENSORED */,
           "charset" =&gt; "utf8",
           "prefix" =&gt; "",
           "prefix_indexes" =&gt; true,
         ],
       ],
       "migrations" =&gt; "migrations",
       "redis" =&gt; [
         "client" =&gt; "predis",
         "options" =&gt; [
           "cluster" =&gt; "predis",
           "prefix" =&gt; /* CENSORED */,
         ],
         "default" =&gt; [
           "url" =&gt; null,
           "host" =&gt; "127.0.0.1",
           "password" =&gt; null,
           "port" =&gt; "6379",
           "database" =&gt; 0,
         ],
         "cache" =&gt; [
           "url" =&gt; null,
           "host" =&gt; "127.0.0.1",
           "password" =&gt; null,
           "port" =&gt; "6379",
           "database" =&gt; 1,
         ],
       ],
     ]
  </code></pre>
  
  <p>UPDATE 2:</p>
  
  <p>It seems that 'forge' is some kind of default login. It seems that sometimes Laravel is not using values from <code>.env</code>. How can I debug this?</p>
  
  <pre><code>$ cat config/database.php | grep -B 5 forge
          'mysql' =&gt; [
              'driver' =&gt; 'mysql',
              'url' =&gt; env('DATABASE_URL'),
              'host' =&gt; env('DB_HOST', '127.0.0.1'),
              'port' =&gt; env('DB_PORT', '3306'),
              'database' =&gt; env('DB_DATABASE', 'forge'),
              'username' =&gt; env('DB_USERNAME', 'forge'),
  --
          'pgsql' =&gt; [
              'driver' =&gt; 'pgsql',
              'url' =&gt; env('DATABASE_URL'),
              'host' =&gt; env('DB_HOST', '127.0.0.1'),
              'port' =&gt; env('DB_PORT', '5432'),
              'database' =&gt; env('DB_DATABASE', 'forge'),
              'username' =&gt; env('DB_USERNAME', 'forge'),
  --
          'sqlsrv' =&gt; [
              'driver' =&gt; 'sqlsrv',
              'url' =&gt; env('DATABASE_URL'),
              'host' =&gt; env('DB_HOST', 'localhost'),
              'port' =&gt; env('DB_PORT', '1433'),
              'database' =&gt; env('DB_DATABASE', 'forge'),
              'username' =&gt; env('DB_USERNAME', 'forge'),
  </code></pre>