Score:0

mysql connection failed when DNS is down

li flag

We had DNS problem in the past with one of our web application coded in php Therefore we used IP addresses instead of the server name and we used HOST file and decided to perform a crash test

When our DNS server is working our web application works fine. However when we switch off our DNS server the code stops working at this line

        $bdd = new PDO('mysql:host=139.XXX.XXX.XXX', 'username', 'pwd',array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
    

It seems that we do not receive answer from the server with the mysql database. The page load during about 20 minutes before we get an error.

Does the remote server reply using reverse DNS lookup ?? So that we don't have answer ?

Thanks for your help !!!

Regards,

Fabian

cl flag
In any case, if DNS fails, you can expect pretty much everything to fail. So the answer is to make your DNS highly available instead, preferably geo-redundantly. Hardcoding IPs is the worst answer to this issue and will most certainly bite you in the rear in the future.
Score:0
tc flag

Sounds like you have to edit the bind-adress in my.cnf?

Check if this helps: How to bind MySQL server to more than one IP address?

Score:0
cn flag

Yes, it does reverse lookup in order to find the matching user/host. https://dev.mysql.com/doc/refman/8.0/en/host-cache.html

The culprit is in the phrase "For each applicable new client connection, the server uses the client IP address to check whether the client host name is in the host cache. If so, the server refuses or continues to process the connection request depending on whether or not the host is blocked. If the host is not in the cache, the server attempts to resolve the host name."

Check https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_skip_name_resolve

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.