Reputation: 115
QueryException SQLSTATE[HY000] [2002] Can't connect to MySQL server on '127.0.0.1' (110)
When I put this project into another server it works fine . Is there any problem with server configuration ?
in database.php
'default' => env('DB_CONNECTION', 'mysql'),
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
],
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => 'projapati',
'username' => 'projapati',
'password' => 'AHt!j![(dl',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
'sslmode' => 'prefer',
],
],
How can I solve this problem?
Upvotes: 0
Views: 1490
Reputation: 2610
Change this
'host' => env('DB_HOST', '127.0.0.1'),
to this
'host' => env('DB_HOST', 'localhost'),
Upvotes: 1