Azure App service database problem

MagoMerlino 101 Reputation points
2025-02-09T16:36:24.42+00:00

I want to transfer a wordpress webiste to Azure App service.

I have run an App Service plan containing: Azure Database for MySQL flexible server and the App service.

After that, I had moved all files of my website into the Azure FTP and I was able to import the old database via : webiste.azurwebsite.net/phpmyadmin (this only after I had increased the max upload size modifying the file /usr/local/etc/php/conf.d/uploads.ini from

https://yoursitename.scm.azurewebsites.net/webssh/host).

I have then updated the wp-config with the right table_prefix, db name,user,password,host.

I still get this error: Error establishing a database connection

Warning: mysqli_real_connect(): php_network_getaddresses: getaddrinfo for webiste-ec46456440-pdbserver.mysql.database.azure.com failed: Name or service not known in /var/www/wordpress/wp-includes/class-wpdb.phpon line1982

Warning: mysqli_real_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo for website-ec46456440-pdbserver.mysql.database.azure.com failed: Name or service not known in /var/www/wordpress/wp-includes/class-wpdb.phpon line1982

php_network_getaddresses: getaddrinfo for 
nottebland-ec46456440-pdbserver.mysql.database.azure.com failed: Name or
 service not known
Azure Database for MySQL
Azure Database for MySQL
An Azure managed MySQL database service for app development and deployment.
897 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,292 questions
{count} votes

2 answers

Sort by: Most helpful
  1. MagoMerlino 101 Reputation points
    2025-02-10T13:25:20.99+00:00

    I have restarted the database and the app,

    but unfortunately i now get a new error:

    Connections using insecure transport are prohibited while --require_secure_transport=ON.
    

  2. Sina Salam 17,571 Reputation points
    2025-02-10T15:18:56.0133333+00:00

    Hello MagoMerlino,

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    I understand that you are having issue with your Azure App service and Azure database while migrating.

    Regarding the information provided, the below are the steps you can use to resolve the issue:

    1. Confirm the exact hostname in the Azure Portal under your MySQL Flexible Server’s "Overview" tab. It should follow the format: <server-name>.mysql.database.azure.com
    2. Ensure there are no typos (e.g., wpdbserver vs. pdbserver).
    3. Test connectivity from the App Service:
      1. Use the App Service’s SSH console (via https://<app-name>.scm.azurewebsites.net/webssh/host).
      2. Run nslookup <db-hostname> to verify DNS resolution.
      3. Run telnet <db-hostname> 3306 to check if port 3306 is reachable.
    4. Check firewall/VNet rules:
      1. Ensure the App Service’s outbound IP addresses are whitelisted in the MySQL server’s firewall.
      2. If using VNet integration, ensure the MySQL server is deployed in the same VNet.

    In this step 2:

    1. Download the Azure CA certificate by navigating to your MySQL server > Connection Security > Download SSL Certificate** (usually DigiCertGlobalRootCA.crt.pem).
    2. Upload the certificate to your App Service by placing it in a persistent folder like /home/site/wwwroot/ssl/ (create the ssl directory if needed).
    3. Update wp-config.php:
              // Database settings
              define('DB_HOST', 'correct-hostname.mysql.database.azure.com');
              define('DB_USER', 'user@mysql-server-name'); // Format: 'user@server-name'
              define('DB_PASSWORD', 'password');
              define('DB_NAME', 'database-name');
              // SSL Configuration
              define('MYSQL_CLIENT_FLAGS', MYSQLI_CLIENT_SSL);
              define('MYSQL_SSL_CA', '/home/site/wwwroot/ssl/DigiCertGlobalRootCA.crt.pem');
         
      
    4. Verify MySQL user privileges by connecting to your MySQL server via Azure Portal’s query editor or mysql CLI:
                ALTER USER 'wp_user'@'%' REQUIRE SSL;
                FLUSH PRIVILEGES;
      

    This is the third step:

    • Never disable require_secure_transport=ON . Instead, enforce SSL as above.
    • Restart the App Service and MySQL server to apply changes.

    If you can follow the steps above, the hostname typo and DNS resolution issues will be resolved, SSL is correctly configured using the Azure CA certificate, and the MySQL user is now required to use SSL in accordance with require_secure_transport=ON, ensuring that the WordPress site connects to the database securely and without errors.

    I hope this is helpful! Do not hesitate to let me know if you have any other questions.


    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.


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.