Can't Connect to MySQL Flexible Server in Azure

Viktor Opara 0 Reputation points
2024-10-16T10:18:24.8+00:00

I'm trying to prevent public access to our production MySQL Flexible Server on Azure by using a private Virtual Network (VNet). However, I'm getting the following error when my application tries to connect to the database:

getaddrinfo ENOTFOUND projectx-mysql-flexible-server.mysql.database.azure.com

Setup:

  • MySQL server is deployed in a private subnet within a VNet.
  • The DNS zone for MySQL is linked to the VNet using a private DNS zone.
  • I've disabled public access to the MySQL server by removing the public firewall rule.

Things I've Checked:

  1. The MySQL server is in a private subnet.
  2. The DNS zone is correctly linked to the VNet.
  3. The application and MySQL server are supposed to be in the same VNet and subnets.

Question: How can I verify that both my application and the MySQL server are correctly configured to use the same VNet and private DNS? What else should I check to fix the ENOTFOUND error?

Azure Database for MySQL
Azure Database for MySQL
An Azure managed MySQL database service for app development and deployment.
841 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Vijayalaxmi Kattimani 80 Reputation points Microsoft Vendor
    2024-10-16T13:23:10.35+00:00

    Hi @Viktor Opara,

    Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.

    As i understand that, you would like to verify your application and the MySQL server configuration in order to use VNet and private DNS. Also need to fix ENOTFOUND error.

    To verify that both your application and the MySQL server are correctly configured to use the same VNet and private DNS, you can perform the following steps:

    1. Check the VNet configuration: Ensure that both your application and the MySQL server are deployed in the same VNet. You can check the VNet configuration in the Azure portal or using the Azure CLI.
    2. Check the private DNS configuration: Ensure that both your application and the MySQL server are configured to use the same private DNS zone. You can check the private DNS configuration in the Azure portal or using the Azure CLI.
    3. Check the DNS resolution: Verify that the DNS name of the MySQL server is resolving correctly from your application. You can use the 'nslookup' command to check the DNS resolution, run the following command from your application server.      nslookup <your-server-name>.mysql.database.azure.com

    I would request you to refer the below mentioned links:

    https://zcusa.951200.xyz/en-us/windows-server/networking/dns/troubleshoot/troubleshoot-dns-server

    https://zcusa.951200.xyz/en-us/azure/mysql/flexible-server/concepts-networking-vnet

    https://zcusa.951200.xyz/en-us/azure/mysql/flexible-server/how-to-troubleshoot-common-connection-issues

    https://zcusa.951200.xyz/en-us/windows-server/administration/windows-commands/nslookup

    https://techcommunity.microsoft.com/t5/azure-database-for-mysql-blog/how-to-resolve-dns-issues-with-azure-database-for-mysql/ba-p/4047706

    Check the firewall rules: Ensure that the firewall rules for the MySQL server allow traffic from the application server. You can check the firewall rules in the Azure portal or using the Azure CLI.

    If you are still experiencing the ENOTFOUND error after verifying the VNet, private DNS, DNS resolution, and firewall rules, you may need to check the application configuration to ensure that it is correctly configured to connect to the MySQL server. You may also need to check the MySQL server logs for any error messages that could provide more information about the issue.

    Hope this helps. Do let us know if you any further queries.

    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.