マイグレーション実行時にエラー(could not connect to server: Connection refused)が出た
マイグレーション実行時に以下のエラーが出ました。
$ docker-compose exec workspace php artisan migrate Illuminate\Database\QueryException : SQLSTATE[08006] [7] could not connect to server: Connection refused Is the server running on host "postgres" and accepting TCP/IP connections on port 5342? (SQL: select * from information_schema.tables where table_schema = public and table_name = migrations and table_type = 'BASE TABLE') at /var/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669 665| // If an exception occurs when attempting to run a query, we'll format the error 666| // message to include the bindings with SQL, which will make this exception a 667| // lot more helpful to the developer instead of just the database's errors. 668| catch (Exception $e) { > 669| throw new QueryException( 670| $query, $this->prepareBindings($bindings), $e 671| ); 672| } 673| Exception trace:
原因
エラーに書いてある通り、laravel/.envのDBのポート番号が間違っているのが原因でした。
キャッシュを削除する
よく使いそうなのでメモ。
$ docker-compose exec workspace php artisan config:clear