This error appears when attempting to make a connection to MySQL or MariaDB using PHP. Following are a list of things to check when this error appears.
Ensure you are port forwarding on ports 80 and 443 in your router
In your PHP connection string, try to connect using the IP address of the LAMP server. If the connection is successful when using the IP address but fails when using the domain name, this suggests there is no entry in the /etc/hosts file on the LAMP server mapping the domain name to the IP address. Map the IP address to the domain name in the /etc/hosts file on the LAMP server.