Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
521 views
in Technique[技术] by (71.8m points)

laravel - IlluminateDatabaseQueryException: SQLSTATE[HY000] [2002] in file Illuminate/Database/Connection.php on line 678

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}()
question from:https://stackoverflow.com/questions/65868338/illuminate-database-queryexception-sqlstatehy000-2002-in-file-illuminate-da

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Only change localhost to your computer's IP address.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...