SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known

前端 未结 16 779
说谎
说谎 2021-01-03 17:56

I download from https://github.com/luciddreamz/laravel Laravel for openshift then upload over my repository over github. This code for connect to database not work. The prob

16条回答
  •  轮回少年
    2021-01-03 18:32

    In my case, it had absolute nothing to do with network issues.

    I had been using my local laravel testing environment using laradock. Because laradock runs the mysql server in a different container, you have to set your mysql host in the .env file to the name of the docker mysql container, which by default is mysql.

    When I switched back to using homestead, it was trying to connect to a host named mysql, when in fact is should be looking on localhost.

    What a DUH moment!

提交回复
热议问题