Troubleshoot private DNS resolution timeouts and SERVFAIL errors

This page applies to Apigee, but not to Apigee hybrid.

View Apigee Edge documentation.

This playbook explains how to diagnose and resolve intermittent or persistent DNS resolution failures, high target connection latency, and SERVFAIL responses when Apigee connects to southbound backend targets using private DNS peering or Cloud DNS forwarding zones.

Symptoms

When Apigee resolves private domain names for southbound target endpoints through Cloud DNS, you might observe the following symptoms:

  • API proxy requests to a backend target configured with a private fully qualified domain name (FQDN) fail intermittently with an HTTP 503 Service Unavailable status code and the TARGET_CONNECT_HOST_NOT_REACHABLE error reason.
  • In an Apigee Debug session, the target endpoint step records the following flow variable values:
    • targetendpoint_main.connectionStatus = FAILED_TO_CONNECT
    • targetendpoint_main.resolvedAddress = address_not_resolvable
  • DNS lookups from a virtual machine (VM) in the peered Virtual Private Cloud (VPC) network using the configured private DNS forwarders intermittently time out across multiple network hops or return a SERVFAIL response, whereas public DNS resolution or direct queries to the final DNS resolver succeed.

Error messages

When private DNS resolution times out or receives a SERVFAIL response, Apigee returns an HTTP 503 Service Unavailable status code with the following JSON error payload:

{
  "fault": {
    "faultstring": "Unable to resolve host api.backend.example.com",
    "detail": {
      "errorcode": "protocol.http.NoResolvedHost",
      "reason": "TARGET_CONNECT_HOST_NOT_REACHABLE"
    }
  }
}

Possible causes

If your target hostname is valid and private DNS peering is already configured, the protocol.http.NoResolvedHost error typically occurs when upstream private DNS resolution exceeds the Apigee DNS lookup timeout window or returns a server failure. If you haven't verified your hostname syntax or initial DNS peering setup, see API requests fail with TARGET_CONNECT_HOST_NOT_REACHABLE error.

The following table lists the possible cause covered in this playbook:

Cause Description Platform
Multi-hop private DNS forwarding timeouts and SERVFAIL errors DNS queries from Cloud DNS traverse multiple on-premises or external DNS forwarding hops, causing cumulative resolution timeouts or intermittent SERVFAIL responses from upstream private DNS servers. Apigee

Cause: Multi-hop private DNS forwarding timeouts and SERVFAIL errors

In Apigee, runtime instances are hosted in a Google-managed tenant VPC network and rely exclusively on Cloud DNS for DNS resolution. You can't configure custom DNS servers, modify resolv.conf, or bypass Cloud DNS directly on Apigee runtime instances.

When Apigee uses private DNS peering, Apigee forwards DNS queries for the peered domain suffix to the producer or Shared VPC host network. If that network uses a Cloud DNS forwarding zone that routes queries through a multi-hop chain (for example, from Cloud DNS to an on-premises DNS forwarder, then to an Active Directory DNS resolver, and then to an external DNS resolver or secure web gateway), each hop adds network and processing latency. If the cumulative resolution time exceeds the Apigee DNS lookup timeout window, or if an upstream private DNS server in the forwarding chain intermittently returns a SERVFAIL response, Apigee fails to resolve the target host and returns the protocol.http.NoResolvedHost error.

Diagnosis

To diagnose multi-hop private DNS resolution timeouts and SERVFAIL errors, follow these steps:

  1. Start a Debug session for the affected API proxy in the Google Cloud console and send a test request that reproduces the HTTP 503 Service Unavailable status code.

    Inspect the target request step in the Debug session results and verify that the flow variables show targetendpoint_main.connectionStatus = FAILED_TO_CONNECT and targetendpoint_main.resolvedAddress = address_not_resolvable.

  2. Identify the peered DNS domains and the target producer VPC network configured for your Apigee organization. Select one of the following options based on your Apigee networking configuration:

    VPC peering enabled

    If your Apigee organization uses VPC network peering, run the gcloud services peered-dns-domains list command to list the peered DNS domains in your producer VPC network:

    gcloud services peered-dns-domains list \
        --network=VPC_NETWORK_NAME \
        --project=PRODUCER_PROJECT_ID

    Replace the following:

    • VPC_NETWORK_NAME: the name of the VPC network peered with Apigee.
    • PRODUCER_PROJECT_ID: the project ID of the Google Cloud project that contains the peered VPC network. In a Shared VPC architecture, specify the host project ID.

    The command returns a list of peered DNS domain suffixes similar to the following output:

    NAME              DNS_SUFFIX
    backend-internal  backend.example.com.

    VPC peering not enabled

    If your Apigee organization doesn't use VPC network peering, call the organizations.dnsZones.list method to inspect your Apigee DNS peering zones:

    curl -X GET \
        -H "Authorization: Bearer $(gcloud auth print-access-token)" \
        "https://apigee.googleapis.com/v1/organizations/ORG/dnsZones"

    Replace the following:

    • ORG: the name of your Apigee organization.

    The command returns the configured DNS peering zones, including the domain, targetProjectId, and targetNetworkId fields.

  3. List the Cloud DNS managed zones in the producer or Shared VPC host project to identify which private forwarding zone matches the target hostname domain suffix:

    gcloud dns managed-zones list --project=PRODUCER_PROJECT_ID

    Inspect the forwarding configuration of the matching zone by running the gcloud dns managed-zones describe command:

    gcloud dns managed-zones describe FORWARDING_ZONE_NAME \
        --project=PRODUCER_PROJECT_ID

    Replace the following:

    • FORWARDING_ZONE_NAME: the name of the private Cloud DNS forwarding zone that matches your target domain.
    • PRODUCER_PROJECT_ID: the project ID of the project that hosts the Cloud DNS zone.

    Note the private DNS server IP addresses listed under forwardingConfig.targetNameServers in the output.

  4. From a Compute Engine VM instance connected to the peered VPC network, run dig or nslookup against each forwarding target IP address to check for resolution timeouts or SERVFAIL responses and inspect the forwarding chain:

    dig @FORWARDER_IP_ADDRESS TARGET_HOST_FQDN A +stats

    Because SERVFAIL errors and multi-hop timeouts can be intermittent, run the query multiple times against each FORWARDER_IP_ADDRESS (and against any downstream internal resolvers in the forwarding chain, if reachable) to compare response status and latency:

    for i in 1 2 3 4 5; do dig @FORWARDER_IP_ADDRESS TARGET_HOST_FQDN A +stats; done

    Replace the following:

    • FORWARDER_IP_ADDRESS: the IP address of each private DNS server from the targetNameServers list.
    • TARGET_HOST_FQDN: the backend target hostname configured in your API proxy, such as api.backend.example.com.

    Inspect the status field in the HEADER section and the Query time field in the dig output:

    ;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 48291
    ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
    ;; Query time: 2140 msec
    ;; SERVER: 10.10.0.53#53(10.10.0.53)

    If the output shows status: SERVFAIL, if the query times out across multiple forwarding hops, or if Query time values are consistently elevated, the private DNS forwarding path is the cause of the TARGET_CONNECT_HOST_NOT_REACHABLE errors.

Resolution

To resolve private DNS resolution timeouts and SERVFAIL errors caused by multi-hop forwarding, create a specific private Cloud DNS forwarding zone for the target domain (TARGET_HOST_FQDN.) to bypass the failing or slow intermediate DNS hops:

  1. If a broad parent or wildcard forwarding zone in your host project (such as example.com.) routes queries through a multi-hop on-premises DNS chain, create a more specific private Cloud DNS forwarding zone for the target hostname or subdomain (such as api.backend.example.com.). Configure the specific zone to forward queries directly to the DNS servers that resolve the target domain without additional forwarding hops:

    gcloud dns managed-zones create SPECIFIC_ZONE_NAME \
        --dns-name="TARGET_HOST_FQDN." \
        --description="Specific forwarding zone for TARGET_HOST_FQDN" \
        --visibility=private \
        --networks=VPC_NETWORK_NAME \
        --forwarding-targets="DIRECT_DNS_SERVER_IP_1,DIRECT_DNS_SERVER_IP_2" \
        --project=PROJECT_ID

    Replace the following:

    • SPECIFIC_ZONE_NAME: a name for the specific forwarding zone, such as specific-target-forwarder.
    • TARGET_HOST_FQDN: the target hostname (FQDN) or subdomain suffix, such as api.backend.example.com (include the required trailing dot in --dns-name="TARGET_HOST_FQDN.").
    • VPC_NETWORK_NAME: the name or full resource URL of the producer or Shared VPC host network peered with Apigee.
    • DIRECT_DNS_SERVER_IP_1,DIRECT_DNS_SERVER_IP_2: a comma-separated list of IP addresses for the DNS resolvers that can resolve the target domain directly.
    • PROJECT_ID: the project ID of the service project or Shared VPC host project where you create the zone.

    Because Cloud DNS evaluates zones using longest-suffix matching, queries for TARGET_HOST_FQDN. use the specific forwarding zone, while queries for other domains continue to use the broader wildcard or parent forwarding zone.

  2. Work with your internal DNS and network teams to address the underlying forwarding chain:

    • Investigate intermittent SERVFAIL responses: Check the health and logs of the configured private DNS servers to identify why a specific DNS server in the forwarding chain is intermittently returning SERVFAIL or timing out.
    • Reduce forwarding hops with a direct CNAME record: If your private DNS forwarder consistently resolves the target hostname to the same canonical domain name, consider configuring a direct CNAME record on the first-hop DNS server to reduce the number of intermediate DNS hops.

Must gather diagnostic information

If the issue persists after you follow the preceding instructions, gather the following diagnostic information and contact Google Cloud Customer Care:

  1. Google Cloud project ID and Apigee organization name.
  2. Affected API proxy name, revision number, and environment name.
  3. Target hostname (FQDN) and the time window and frequency of the errors.
  4. Downloaded Debug session file showing the protocol.http.NoResolvedHost error and flow variables.
  5. Output of the gcloud services peered-dns-domains list and gcloud dns managed-zones describe commands from your producer project.
  6. Complete output of repeated dig @FORWARDER_IP_ADDRESS TARGET_HOST_FQDN A +stats queries run from a Compute Engine VM in the peered VPC network.