This topic summarizes typical issues and troubleshooting methods for CDN origin fetch scenarios by symptom, covering origin fetch failures and 5xx errors, redirect loops, 4xx errors, OSS origin fetch errors, and abnormal origin fetch content and behavior.
Symptom quick reference
First locate the entry point based on the phenomenon observed on the client, and then follow the steps in the corresponding section to troubleshoot item by item.
Symptom or status code | Common cause | Troubleshooting entry |
502 Bad Gateway | The origin protocol or port does not match what the origin server listens on, origin SNI is missing, or the certificate of the origin server is invalid | How do I troubleshoot a 502 error returned during origin fetch? |
502 returned when the origin protocol is set to Follow | The client accesses over HTTPS, CDN performs origin fetch over HTTPS accordingly, but the origin server does not support HTTPS | How do I troubleshoot a 502 error when the origin protocol is set to Follow? |
504 Gateway Timeout | The origin server responds slowly, a firewall silently drops packets, or the origin HTTP request timeout is too short | |
503 Service Temporarily Unavailable | The service on the origin server is abnormal or overloaded, the origin server throttles requests, or security software blocks origin fetch IP addresses | |
ERR_TOO_MANY_REDIRECTS | The origin server is configured with a forced redirect from HTTP to HTTPS, while CDN performs origin fetch over HTTP | Redirect loop caused by a forced redirect on the origin server |
The redirect loop appears only after the origin host or origin SNI is configured | After the origin server matches the target site, the forced redirect rule of that site takes effect | Redirect loop after the origin host and origin SNI are configured |
404, 403, 500, or 502 returned after the origin host is configured | The origin host does not match the virtual host of the origin server (server_name, ServerName, or the IIS host name) | |
403 Forbidden | An access control rule on the CDN side is hit, or hotlink protection, IP restrictions, or the WAF of the origin server blocks the origin fetch request | |
A 404 error is returned for access through CDN, but direct access to the origin server works | The origin host is incorrect, a node has cached an old 404 response, or the request path differs in letter case or encoding | A 404 error is returned during origin fetch, but direct access to the origin server works |
bucket acl error | The OSS bucket on the origin is in private mode, and origin fetch from private OSS buckets is not enabled | |
forbidden by kms error | Objects in OSS are encrypted with KMS, and the CDN origin fetch role lacks KMS decryption permissions | |
forbidden to list buckets error | Origin fetch from private OSS buckets conflicts with the default homepage configuration of OSS static website hosting, and access to the root directory is denied | |
Device adaptation stops working (different devices receive the same page) | The 302 redirect response for the first device was cached, and other devices that access the same URL hit that cache | |
Page redirects fail or some resources are inaccessible | Ignore URL parameters causes requests with different parameters to share the same cache, or the origin host does not match | |
Large file downloads are interrupted, or resumable downloads or video seeking fail | The origin server does not support Range requests, or the origin server responds with a non-206 status code to Range origin fetch |
How to determine whether the issue occurs during origin fetch
Origin fetch issues usually manifest as 5xx or 4xx errors when the accelerated domain name is accessed, or responses that differ from expectations. Use the following steps to identify the responsible party first, and then go to the corresponding section to troubleshoot.
Verify whether the request goes through CDN: Run
curl -I http(s)://accelerated-domain/resource-pathto check the response headers. If the response headers contain CDN signature fields such asX-CacheorVia, the request has reached a CDN node. If these fields are absent, rundig accelerated-domainto check whether the resolution result is the CNAME assigned by CDN. If the resolution is incorrect, fix the DNS resolution first so that the accelerated domain name resolves only to the CNAME record provided by CDN. If the resolution is correct but CDN signature response headers are still absent, investigate DNS hijacking or local hosts file bindings.NoteA
Server: AliyunOSSresponse header alone does not prove that the request reached OSS directly. When OSS serves as the origin of CDN, CDN may pass through this response header after origin fetch. Rely on the DNS resolution result and CDN signature response headers instead.Determine whether the exception comes from the cache or from origin fetch: After confirming that the request goes through CDN, check
X-Cache.If the value is
HIT, the request hit the CDN cache. The abnormal response may come from an old cache. Run a URL refresh first, and then access again to reproduce the issue.If the value is
MISS, CDN has already performed origin fetch. If the response is still abnormal, the issue most likely occurs in the origin fetch path or the response of the origin server.Compare direct access to the origin server with access through CDN: Bind the local hosts file, or access the IP address or domain name of the origin server directly. If direct access to the origin server works but access through CDN fails, focus on the origin fetch configuration (origin protocol, port, origin host, and origin SNI) and how the origin server handles CDN origin fetch IP addresses. If direct access to the origin server also fails, fix the issue on the origin server first. No adjustment is required on the CDN side.
Compare CDN access logs with origin server access logs: If the origin server logs do not contain the request, the origin fetch request failed before it reached the origin server. Check DNS resolution, network connectivity, the TLS handshake, and security groups or firewalls. If the origin server received the request but returned an error, compare the request path, Host, User-Agent, and Referer fields in the logs on both sides to locate the difference field by field.
Origin fetch failures and 5xx errors
Redirect exceptions
Origin fetch 4xx errors
Distinguish the troubleshooting focus by status code:
404: The request reached the origin server, but the origin server cannot find the resource under that virtual host. Focus on whether the origin fetch request path is correct and whether CDN has cached an old 404 response.
403: The origin server rejected the request. Focus on whether Referer-based hotlink protection, the IP address whitelist, WAF rules, and the Host header match the security policies of the origin server.
OSS origin fetch errors
Abnormal content and behavior
Common operations
Several of the preceding scenarios share two operations: refreshing the cache and maintaining the origin fetch IP whitelist. They are described here together.
When to refresh the cache:
After you modify the origin fetch configuration (origin protocol, origin port, origin host, origin SNI, cache rules, and so on), the new configuration takes effect only for subsequent origin fetch requests. Abnormal responses already cached on the nodes (such as 403, 404, and 301/302 redirects) do not expire automatically. Therefore, we recommend that you run a refresh after modifying the configuration. Otherwise, you may mistakenly conclude that "the configuration has not taken effect." After the configuration is modified, it needs to be distributed to all nodes across the network, which usually takes a few minutes.
Choosing a refresh method:
URL refresh: Suitable when the exact address of the abnormal resource is known. It precisely clears the cache of a single resource.
Directory refresh: Suitable when resources under an entire directory may be affected, for example when the whole site returned 404 errors after the origin host was modified.
Regex refresh: Suitable when you need to refresh in bulk by path pattern or file name extension.
To refresh the entire site, you can run a directory refresh on the root directory of the domain name, or call the RefreshObjectCaches API operation with the Force parameter set to true. For the specific operations, effective times, and daily quota limits of each refresh type, see Purge and prefetch resources.
Maintaining the origin fetch IP whitelist:
In multiple scenarios of 502, 503, and 504 errors, as well as origin-side 403 errors, the root cause is that the origin server blocks or throttles CDN origin fetch IP addresses. Origin fetch IP address ranges change with node scheduling and are updated periodically. After the whitelist becomes outdated, origin fetch failures appear again.
We recommend that you periodically obtain the latest list and synchronize it to the security groups, firewalls, WAF, and rate limit rules of the origin server. To obtain the L2 node origin fetch IP list of a specified domain name, use the DescribeL2VipsByDomain API operation. If the origin server controls source IP addresses through security groups or firewall rules, we recommend that you integrate the preceding API operation into a scheduled task to periodically pull the latest origin fetch IP address ranges and update the whitelist automatically.