I developed a Web Portal on Windows Operating System using Angular-7 as the frontend and Laravel-5.8 as the backend. Before deployment, I tested everything on the local machine and it was okay.
The Linux Ubuntu server IP is: 20.10.10.122 The Laravel file path is:
http://120.10.10.122/client-app/backend
.env
APP_NAME=Client
APP_ENV=local
APP_KEY=base64:QT/LLNA/aduSekOXF4/CsY1iYEcRwwwwssssssHxuFs=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=http://localhost/
DB_PORT=3306
DB_DATABASE=client
DB_USERNAME=jdggsss
DB_PASSWORD=kjhgfdddd
However, when I deployed to Linux Ubuntu-18 Server, I ran the application. When the user tried to login, I got this error:
message: "SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution (SQL: select * from
users
whereactive
= 1 anddeleted_at
is null andusers
.deleted_at
is null limit 1)"
Why am I getting the error and how do I resolve it?
Change your environment variable to connect to the local MySQL server via TCP
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=client
DB_USERNAME=jdggsss
DB_PASSWORD=kjhgfdddd
Your DB_HOST
environment variable is clearly wrong. You added the http://
URI Scheme to it. The http://
scheme is for identifying a http protocol, MySQL don't use it.
You should use only the hostname
, without prefixes:
DB_HOST=localhost
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With