Last updated 2018-04-24
Fastly automatically detects loops resulting from service configuration errors. When a loop is detected, Fastly blocks the requests and generates an error message. Loops can occur when the same hostname is configured as both the domain and the origin server, and the CNAME record for the domain is pointed at Fastly. For example, loop detection will be triggered if you set
www.example.com as the domain and the origin server in your Fastly service and you add a CNAME DNS record for
www.example.com that points at Fastly.
How to avoid triggering loop detection
To avoid triggering loop detection, you should verify the hostname of your origin server is not the same as the domain using one of the following two options:
- Create a DNS hostname (
origin.example.com) with the appropriate A and AAAA DNS records for your origin server, and use that origin DNS hostname in your Fastly service configuration. This ensures the origin (
origin.example.com) is different than the domain (
www.example.com) on your service. We recommend this option. If you make changes to the DNS records for
origin.example.comin the future, Fastly will automatically detect and use those changes.
- Use an IPv4 address instead of a DNS hostname for your origin's address within your Fastly service's configuration. If the origin server's IP address changes in the future, you'll need to update and activate a new version of your Fastly service configuration.
Example error message
When Fastly detects a loop, an error message similar to the one displayed below will appear in the headers.
1 2 3 4 5 6 7 HTTP/1.1 503 Loop detected Error-Reason: loop detected Connection: close Content-Type: text/plain Fastly-Host: <hostname> Fastly-FF: <hostname> Server: Varnish