How do I resolve the "Name or service not known" error in Amazon RDS for MySQL?

2 minute read
0

I want to resolve the "Name or service not known error" in Amazon Relational Database Service (Amazon RDS) for MySQL error logs.

Short description

When client authentication is in progress, Amazon RDS for MySQL performs a reverse DNS lookup on the client's hostname that's trying to connect. RDS for MySQL checks whether the hostname is in the host cache. If it doesn't exist, then the server resolves the IP address to a hostname and resolves the hostname back to an IP address. If RDS for MySQL can't perform the DNS lookup, then it logs one of the following error messages and continues the client authentication process:

"Host name could not be resolved: Name or service not known"

"IP address xxx.xxx.xxx.xxx/n could not be resolved: Name or service not known"

For a given host, RDS for MySQL only tries to perform a reverse DNS lookup for the first connection from that host. You won't see error messages for subsequent user connections from that host. Note that Amazon RDS intentionally limits a reverse DNS resolution for MySQL client connections within virtual private cloud (VPC) networks.

Note: In most cases, the preceding error messages can be ignored. However, the reverse DNS lookup process might cause a significant performance overhead and slow down the connection attempt.

Resolution

To resolve these error messages, turn on the skip_name_resolve parameter in a custom RDS for MySQL parameter group.

Complete the following steps:

  1. Create a custom parameter group in RDS for MySQL.
  2. Set the skip_name_resolve parameter to 1.
  3. Associate the custom parameter group with your RDS for MySQL instance.
  4. Reboot the instance to apply the custom parameter group.

Note: When you turn on the skip_name_resolve parameter, the parameter turns off reverse DNS lookup.

For more information, see DB parameter groups for Amazon RDS DB instances.

Related information

DNS lookups and the host cache on the MySQL website

AWS OFFICIAL
AWS OFFICIALUpdated 3 months ago
2 Comments

This parameter is already set to 1 in my cluster db parameter group but I've still randomly in my logs the error "Name or service not known". For information the error appear from our laravel app. Thanks

replied 8 months ago

Thank you for your comment. We'll review and update the Knowledge Center article as needed.

profile pictureAWS
MODERATOR
replied 8 months ago