framework: [5.8.13] 'SQLSTATE[HY000] [2002] Connection refused' if docktrine/dbal installed

  • Laravel Version: 5.8.13
  • PHP Version: 7.2.15
  • Database Driver & Version: none

Description:

You can’t run composer update and call artisan commands if add Schema::defaultStringLength calling to AppServiceProvider and you have doctrine/dbal package.

On running composer require doctrine/dbal:

In PDOConnection.php line 31:
                                             
  SQLSTATE[HY000] [2002] Connection refused  
                                             

In PDOConnection.php line 27:
                                             
  SQLSTATE[HY000] [2002] Connection refused 

On 5.8.12 works fine.

Steps To Reproduce:

  1. Create new project:
composer create-project --prefer-dist laravel/laravel blog
  1. Fix 1071 Specified key was too long error: Using official documentation: https://laravel.com/docs/5.8/migrations#indexes

Add Schema::defaultStringLength calling to AppServiceProvider

use Illuminate\Support\Facades\Schema;

/**
 * Bootstrap any application services.
 *
 * @return void
 */
public function boot()
{
    Schema::defaultStringLength(191);
}
  1. Try to install doctrine/dbal package:
composer require doctrine/dbal

You will get error:

In PDOConnection.php line 31:
                                             
  SQLSTATE[HY000] [2002] Connection refused  
                                             

In PDOConnection.php line 27:
                                             
  SQLSTATE[HY000] [2002] Connection refused  
                                             

Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 2
  • Comments: 20 (10 by maintainers)

Commits related to this issue

Most upvoted comments

@driesvints this also breaks the package:discover command that runs after composer install. I noticed this because our build process started failing as there is no .env and no database available yet at the composer install step in our build process.

After applying your revert from https://github.com/laravel/framework/pull/28301 it started working again.

Hopefully this can be tagged soon and properly addressed later. 😃