0

When i type php artisan migrate from my pc it throws an error.

1 D:\xampp\htdocs\cms\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70 PDOException::("SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it")

2 D:\xampp\htdocs\cms\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70 PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=cms", "homestead", "secret", [])

But when I ssh into homestead with vagrant ssh migration works.

r0pe-12
  • 57
  • 2
  • 9
  • 4
    Homestead is run inside of a Virtual Machine. Your computer will use `localhost` as the computer OS itself, not the virtual machine, so it won't be able to connect to the database. You'll need to run all migrations and artisan commands inside of the virtual machine. – aynber Apr 12 '22 at 19:58

1 Answers1

1

You just need to edit your .env file to look like this

DB_CONNECTION=mysql
DB_HOST=ip that you specified inside your Homested.yaml
DB_PORT=3306
DB_DATABASE=db_name
DB_USERNAME=homestead --- default homestead db username
DB_PASSWORD=secret    --- default homestead db passwprd
r0pe-12
  • 57
  • 2
  • 9