Reputation: 3965
I am using laravel 5.7 and i am getting this error. But its working fine for older versions. i am using xamp with php 7.3.* . Here is my code
.env
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3308
DB_DATABASE=project
DB_USERNAME=root
DB_PASSWORD=
DB_DEFAULT=mysql
database.php
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3308'),
'database' => env('DB_DATABASE', 'project'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => false,
'engine' => null,
'default' => env('DB_DEFAULT', 'mysql')
],
Database is fine and i tried connecting with test.php file, its connecting fine but have problem with laravel 5.7
Upvotes: 0
Views: 207
Reputation: 5552
This error usually means the target machine was reachable, but is not listening on that port.
Some things to check:
php artisan config:clear
If the database is not on your local machine, then it could easily be a firewall setting causing the problem.
Upvotes: 2
Reputation: 3965
After a lot of research about laravel 5.7 and xamp, i found the solution. It was basically the cache issue in the file bootstrap/cache/config.php
.
It was reading this config cache file instead of my new file. I removed it and not its working fine. I am very thankful all of you.
Upvotes: 0
Reputation: 1615
XAMPP to check your PORT number then change DB_PORT. I hope it works
Upvotes: 0