Search code examples
amazon-web-servicesdnsamazon-cloudfrontamazon-route53aws-api-gateway

AWS API Gateway custom domain occasional "server DNS address could not be found"


I have set up a custom domain on API Gateway, it is a subdomain. api.example.com. The gateway endpoints are pointing to lambda functions. When making a GET request to the subdomain, I am occasionally (and often) getting the error "server DNS address could not be found". It seems like it could be related to the Lambda cold start, but I can't be sure. If it was related to the cold start, wouldn't the request just timeout or hang, instead of sending back, in particular, a DNS error? The DNS error makes me think the cold starting Lambda isn't the issue.

Also, I need to hit the request 5-10 times before it begins returning successful responses.I do this manually right now, so there are brief pauses between each request.

The error seems to be domain specific too. If in one browser tab I make the request 5+ times, it begins to return successfully, but from another server, on a domain somewhere, I have to hit it 5+ times to get a successful response even though it is currently returning successfully from another domain or server. To me, this rules out lambda cold start being the issue, no?

The domain is registered in route 53. I have a hosted zone for example.com, and in that hosted zone I have an A record for api.example.com. The A record target is set to the CloudFront public DNS setup by API Gateway when I added the custom domain.

One of my questions is: Is this configuration incorrect? Should the subdomain be in its own hosted zone, with a new NS record for api.example.com created in the parent domain pointed to the subdomain's hosted zone? Could this configuration be my issue?


Solution

  • I don't think that is related to Lambda's cold start. It seems like you are having issues with DNS records. The DNS record will take up to 48 hours to propagate across. If you still see this issue, I encourage you to contact Route53 support. They should be able to help you on DNS issue.