I have had a lot of reading on this issue, but I have not found an answer.
I have a PDO connection to mariadb 10.5 through php7.4
My problem: If I go to the url directly on browser, the connection goes through. If I try to access from another php file through file_get_contents or cUrl, the error ocurrs.
$this->conn = new PDO("mysql:host=".$this->host.";dbname=".$dbname, $this->username, $this->password);
I have tried to use IP address, localhost, 127.0.0.1 as host to no avail.
I've also tried setting port=8889 like advised elsewhere, binding mariadb to 0.0.0.0 or even IP
Repeat: Problem happens only when called though another php script, or when my companion android app hits the php page. (Volley error) It doesn't occur when I load it through the browser. I feel like screaming.
Yeah, CentOS 8, Openlitespeed, Php 7.4, MariaDb 10.5
some of my reading n trials... PHP Connection failed: SQLSTATE[HY000] [2002] Connection refused