Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

GodziLaravel's avatar

SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: NO)

Hello,

I decided to create .env.testing file to override the .env file for testing .

then , I :php artisan config:cache --env=testing

vagrant@homestead:~/code/crm$ php artisan config:cache --env=testing
Configuration cache cleared!
Configuration cached successfully!

But after that the project is down 'error 500' and every artisan command returns this error message :

SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: NO) 

It's like the .env does not exists !

I also try to clear cache , but also all clear cache command s returns the same error :

vagrant@homestead:~/code/crm$ php artisan config:clear

   Illuminate\Database\QueryException  : SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: NO) (SQL: select * from `teamleader_apis` limit 1)

  at /home/vagrant/code/crm/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
    660|         // If an exception occurs when attempting to run a query, we'll format the error
    661|         // message to include the bindings with SQL, which will make this exception a
    662|         // lot more helpful to the developer instead of just the database's errors.
    663|         catch (Exception $e) {
  > 664|             throw new QueryException(
    665|                 $query, $this->prepareBindings($bindings), $e
    666|             );
    667|         }
    668|

  Exception trace:

  1   App\Console\Commands\DemoCron::__construct()
      [internal]:0

  2   Doctrine\DBAL\Driver\PDOException::("SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: NO)")
      /home/vagrant/code/crm/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:31

  Please use the argument -v to see more details.
0 likes
5 replies
bugsysha's avatar
bugsysha
Best Answer
Level 61

Have you tried deleting

bootstrap/cache/config.php
1 like
souravmajumdar2002's avatar

@bugsysha

Yes I had the same issue. Got fixed, by deleting "bootstrap/cache/config.php"

I am using php 8.2.3 Laravel 8.83 Vagrant Vertual box 6.1

Thank you so much @bugsysha

bugsysha's avatar

You are very very very welcome. Best luck.

1 like
souravmajumdar2002's avatar

@bugsysha

Yes I had the same issue. Got fixed, by deleting "bootstrap/cache/config.php"

I am using

php 8.2.3

Laravel 8.83

Vagrant

Vertual box 6.1

Thank you so much @bugsysha

Please or to participate in this conversation.