My laravel 5 application was working until I tried to put it on a live ubuntu server and then I ran into this error when running "php artisan migrate":
[PDOException] SQL STATE[HY000] [2003] Can't connect to MySQL server on '162.243.167.251' (111)
I have checked every forum on the internet trying to find the solution including:
- Can't connect to MySQL server error 111 [closed]
- Can't connect to MySQL server (111) even after changing bind-address
- Laravel can't connect to DB
- Can't connect to MySQL on live with Laravel 5
- ERROR 2003 (HY000): Can't connect to MySQL server (111)
I have connected to the database through my command line as seen here
This is my .env setup:
APP_ENV=local
APP_KEY=base64:9wh57LsV7Wnf0QVjr9KJE2Jw6Makot1wptoVW+O9Ky8=
APP_DEBUG=false
APP_LOG_LEVEL=debug
APP_URL=http://foo.com
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=foodb
DB_USERNAME=foouser
DB_PASSWORD=foopass
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=log
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
...
And here is my config/database.php:
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'foodb'),
'username' => env('DB_USERNAME', 'foouser'),
'password' => env('DB_PASSWORD', 'foopass'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
I was wondering if my connections could be wrong or if I am missing something else.