1

I have problem on connecting Laravel 5 to MySQL on live server, it seems ok on localhost but when I uploaded it to live server, it wont connect saying:

PDOException in Connector.php line 47: SQLSTATE[HY000] [2003] Can't connect to MySQL server on '10.0.0.131' (111)

Here are my config

LOCAL SERVER:

config/database.php

'mysql' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST', '127.0.0.1'),
            'database'  => env('DB_DATABASE', 'MY_DATABASE_NAME'),
            'username'  => env('DB_USERNAME', 'MY_USERNAME'),
            'password'  => env('DB_PASSWORD', 'MY_PASSWORD'),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
],

.env

APP_ENV=local
APP_DEBUG=true
APP_KEY=0jxkNPPT1PVVx0sFdMpxfVeqe5C24HLP

DB_HOST=127.0.0.1
DB_DATABASE=MY_DATABASE_NAME
DB_USERNAME=MY_USERNAME
DB_PASSWORD=MY_PASSWORD

CACHE_DRIVER=file
SESSION_DRIVER=file

LIVE SERVER:

config/database.php

'mysql' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST', '10.0.0.131'),
            'database'  => env('DB_DATABASE', 'MY_DATABASE_NAME'),
            'username'  => env('DB_USERNAME', 'MY_USERNAME'),
            'password'  => env('DB_PASSWORD', 'MY_PASSWORD'),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
],

.env

APP_ENV=local
APP_DEBUG=true
APP_KEY=0jxkNPPT1PVVx0sFdMpxfVeqe5C24HLP

DB_HOST=10.0.0.131
DB_DATABASE=MY_DATABASE_NAME
DB_USERNAME=MY_USERNAME
DB_PASSWORD=MY_PASSWORD

CACHE_DRIVER=file
SESSION_DRIVER=file
halfer
  • 19,824
  • 17
  • 99
  • 186
oldstyle inn
  • 105
  • 1
  • 1
  • 6

1 Answers1

1

It doesn't seem to be a configuration error, assuming you did want to connect to 10.0.0.131 and you did not change the default listening port. because the client tries to connect to the database you specified, but it can't due to a connection refused error, which tells you that there is an underlying TCP problem.

Possible cases are:

  1. Service not running
  2. Service not listening on external connections
  3. Firewall blocking connections
  4. Network issues

You should try to log in to your remote server and, from there, connect to your database via some shell command to verify you actually can.

darioguarascio
  • 1,077
  • 11
  • 15
  • thanks for the response :), it seems that it was network issue, when i run ifconfig command on my live server, it doesn't show the eth1 but it is fixed now by using this command "ifconfig eth1 10.0.0.131 up" – oldstyle inn Apr 01 '15 at 23:15