Answer the question
In order to leave comments, you need to log in
Why do I get SQLSTATE[HY000] [2002] Connection refused, while database migrations work?
Trying to use YII locally with docker. Set up the DB. Migrations work fine, but when I try to write or read something from the user table, for example, I get an error:
Database Exception – yii\db\Exception
SQLSTATE[HY000] [2002] Connection refused
Caused by: PDOException
SQLSTATE[HY000] [2002] Connection refused
in /var/www/project.test/vendor/yiisoft/yii2/db/Connection.php at line 687
Answer the question
In order to leave comments, you need to log in
Correct answer
I had to make TWO(!) configs . Separately for the console and for the rest of the application. difference in
dsn.
For the console
'dsn' => 'mysql:host=127.0.0.1;dbname=project',
For the rest of the application
'dsn' => 'mysql:host=mysql;dbname=project',
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question