0
votes

When running php artisan migrate, It gives following error message

1 PDOException::("SQLSTATE[HY000] [2002] Connection refused") /Users/redblac/olivertes/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70

2
PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=oliverte", "root", "", []) /Users/redblac/olivertes/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70

Turkish language

EDIT: Çözüm - Veritabanında password no özellikli yeni bir kullanıcı oluşturdum ve mamp kullandığım için .env ye DB_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock ekledim sorun çözüldü.

1
Try DB_HOST=localhost instead of 127.0.0.1svikramjeet
Are you using Docker by any chance?Bram Verstraten
It is not laravel migrate issue ! It is a db connection issue ! Check your db info again and laravel envhs-dev2 MR

1 Answers

1
votes

The exception means artisan is not able to connect to your database. Try figuring out the following things:

  • Make sure you have a database up and running
  • Make sure the database is not behind a firewall
  • Make sure you can connect to the database via a separate sql client
  • Make sure you have your database credentials configured correctly in your .env file
  • You could check out Laravel documentation on databases and environment configuration

If you want more help on this, try providing us with some more information as to how you have setup your development environment.