mysqli connection attempt failed after about 20 seconds
I'm trying to set up a web server at home, using XAMPP v3.2.2, running on a 32-bit Windows 10 tablet.
- Apache/2.4.38 (Win32)
- PHP Version 7.3.2
- mysql Ver 15.1 Distrib 10.1.38-MariaDB, for Win32 (AMD64)
The DNS setting for my domain include an A record, pointing to my external (ISP assigned, and the same for years) IP address, both for
www.mydomain.mytld and for
Port forwarding for port 80 to the server has been set up in my router.
httpd.conf file includes a section:
<VirtualHost *:80> ServerName www.mydomain.mytld ServerAlias *.mydomain.mytld </VirtualHost>
In MySQL, database user
UPDATE privileges for the
database accessed from
In the .php file I connect to the database using:
$dbUrl = "127.0.0.1"; $dbUser = "username"; $dbPass = "password"; $dbName = "database"; $db = new mysqli($dbUrl, $dbUser, $dbPass, $dbName);
This works fine when I access this on the server itself (using http://127.0.0.1/).
It also works fine when I access the same from another computer in the home network using the server's network address (http://192.168.178.35/).
It also works fine when I access the same from another computer in the home network using my external (ISP assigned) IP address.
But ... when I try the same using my domain name it fails: "Warning: mysqli::__construct(): (HY000/2002): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond." at the
$db = new mysqli(... statement.
localhost and even the server's network address (
$dbUrl, and also tried including the port number
3306, all to no avail.
root user with all privileges too, results are still the same.
Other pages on the same server (both .html and .php) that do not use the database, do work fine using my domain name.
Somewhere on the internet I found maybe this could be solved by commenting out (with a
::1 localhost line in the
%WINDIR%\system32\drivers\etc file, but that line is already commented out in my hosts file.
Since everything works fine using my external IP address, just not using my domain name, I expect I'm simply missing some directive(s) somewhere in one of the many configuration files, but I can't find what I'm missing.
Any ideas, anyone?
Thanks in advance.