All Products
Search
Document Center

API Gateway:Troubleshoot D504CO errors

Last Updated:Sep 22, 2023

This topic describes how to troubleshoot commonly seen D504CO errors based on the error message returned in the response.

1. Backend service connect failed 'Timeout connecting to 172.X.X.1:80'

Cause: The connection between API Gateway and the backend service fails due to a timeout error.

Solutions:

  • Check whether the backend service URL is correct.

  • If the backend service is deployed on an Elastic Compute Service (ECS) instance, check the security group settings to see whether the access is allowed. Make sure that the egress IP address of API Gateway is allowed access by the security group.

  • Check whether the backend service has an active blacklist or whitelist that denies access from API Gateway, whether the backend application program is started, and whether the backend server has an active firewall setting that blocks access from API Gateway.

  • If the backend service is of the virtual private cloud (VPC) type and the access is made across regions or from an on-premises data center over Cloud Enterprise Network (CEN), configure the return route. For more information, see Access to cloud services.

2. Backend service connect failed 'Connection is closed'

Cause: The backend service sends a FIN packet to close the connection.

Solution: This bug was fixed in August 2023 by adding the retry feature, in which API Gateway retries to connect to the backend server upon receiving a FIN packet from the backend service. If you purchased your dedicated instance before August 2023, you can submit a ticket to have your instance updated.

3. Backend service connect failed 'Connection refused'

Cause: The backend service denies the connection request from API Gateway.

Solution: Check your backend service for causes.

4. Backend service connect failed 'Connection lease request time out'

Cause: API Gateway has run out of connection resources in the connection pool.

Solution: Upgrade your API Gateway instance. For more information about instance types, see Instance types.

Note

Data is transmitted serially in a persistent connection over HTTP. This means that the sender must wait for the previous request to be acknowledged before the sender can send the next request. You can plan the size of the outbound connection pool for your API Gateway instance based on this rule.

Connections with the backend service are allocated from the outbound connection pool. If you purchased an instance of the api.s1.small type, the connection pool size is 1,200. Assume that the backend service requires one second to respond for each request, api.s1.small supports up to 1,200 outbound requests per second (RPS). If more than 1,200 requests are sent to the backend service in a second, the connection pool runs out, and the excess requests wait in a queue for 500 milliseconds. If a request still fails to be sent, the Backend service connect failed `Connection lease request time out` error is returned to the client.