All Products
Search
Document Center

Error 2005 (HY000) or 2002: Unknown MySQL server host or unknown name or service

Last Updated: Jun 20, 2019

Symptom

When you connect to an RDS for MySQL or MariaDB TX instance, one of the following three errors is reported:

  • ERROR 2005 (HY000): Unknown MySQL server host ‘xxxxxxx’ (110 or 11004)
  • SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
  • Name or service not known

Cause

Your Domain Name Server (DNS) cannot parse IP addresses.

Solution

  1. Check whether the RDS connection address (a string) that you enter is correct. The address may be incorrect due to any of the following reasons:

    • The format of the entered address is invalid. For example, in the following figure, the valid address format is rm-XXX.XXX.rds.aliyuncs.com.

      s12

    • You use a public address to establish a connection. However, this public address has been released.

    • The entered address exceeds the length limit. As a result, the address is split into parts.

  2. If the RDS connection address that you enter is correct but one of the preceding three errors is reported, change your DNS IP address to the DNS IP address of the Alibaba Cloud:

    • If you want to establish a connection via an intranet in a classic network, change your DNS IP address to 10.143.22.116 or 10.143.22.118.

    • If you want to establish a connection via an intranet in a Virtual Private Cloud (VPC), change your DNS IP address to 100.100.2.136 or 100.100.2.138.

    • If you want to establish a connection via the Internet, change your DNS IP address to 223.5.5.5 or 223.6.6.6.

FAQ

Can I use an IP address instead of a string-type connection address to connect to an RDS instance?

You can run the ping RDS connection address command to check the IP address of the RDS instance. However, we recommend that you do not use an IP address to establish a connection. This is because an IP address changes along with tasks such as migration and active/standby switchover. We recommend that you use a string-type connection address because such a string never changes.