I have Laravel installed on Mac using docker. I connecting to it with postman
The method ge returns this error:
IlluminateDatabaseQueryException: SQLSTATE[HY000] [2002] Connection refused (SQL: select * from `flights`) in file /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php on line 678 #0 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php(752): IlluminateDatabaseConnection->runQueryCallback() #1 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php(732): IlluminateDatabaseConnection->tryAgainIfCausedByLostConnection() #2 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php(641): IlluminateDatabaseConnection->handleQueryException() #3 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php(346): IlluminateDatabaseConnection->run() #4 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2313): IlluminateDatabaseConnection->select() #5 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2301): IlluminateDatabaseQueryBuilder->runSelect() #6 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2796): IlluminateDatabaseQueryBuilder->IlluminateDatabaseQuery{closure}()
Advertisement
Answer
Only change localhost
to your computer’s IP address.