Assumptions:
Server OS: AlmaLinux 8.9
Two IP addresses (a public and a private one) assigned to OS
SELinux: Disabled
WebServer: OpenLitespeed (Managed by DirectAdmin)
LSPHP version 5.6.4
Issue:
Trying to connect to remote MariaDB database using mysqli connection in PHP code running on OpenLitespeed web server fails with “connection refused” error.
Connection is established when running the PHP code using php cli:
/usr/local/php56/bin/php /path/to/test.php
Hints:
I ran tcpdump on port 3306 and saw the transmitted packets when the connection is established using PHP cli, but no packets are transmitted when accessing the page via Web Server.
Here’s what I already tried:
I allowed httpd to connect to network in SELinux policy and even disabled SELinux but still no luck.
I tried connecting to the database using both mysql cli and PHP cli which works fine.
I need some hints to correct the connection issue via php code running on the web server.