• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Issue MySQL php_network_getaddresses: getaddrinfo failed: Name or service not known

JohnWorks

New Pleskian
Hello community,

I have a problem connecting to my database. Remote Access is enabled (Go to Tools & Settings > Database Servers > Settings > click Local MySQL Settings: Select the Allow local MySQL server to accept external connections checkbox, and then click OK Link).

Database name, user and password are correct. Hostname is: localhost:3306

PHP: 7.4.30 FPM-Anwendung (Apache) mysqli is enabled

The data is in a subdomain, which is registered as a separate application.

PHP:
    private $servername = "localhost:3306";
    private $username = "user";
    private $password = "pw";
    private $dbname = "dbname";

    private $conn;

    function __construct() {

        $this->conn = new mysqli($this->servername, $this->username, $this->password, $this->dbname);

        if ($this->conn->connect_error) {

            die("Connection failed: " . $this->conn->connect_error);

        }

        $this->conn->set_charset("utf8");

    }

Displayed error in the browser:
Code:
Connection failed: php_network_getaddresses: getaddrinfo failed: Name or service not known

Displayed error in the log:
Code:
AH01071: Got error 'PHP message: PHP Warning: mysqli::__construct(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/vhosts/domain/subdomain.domain.de/db.php on line 30PHP message: PHP Warning: mysqli::__construct(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/vhosts/domain/subdomain.domain.de/db.php on line 30', referer: https://subdomain.domain.de/login.php

Plesk Obsidian 18.0.45 (Ubuntu) on IONOS
 
Back
Top