Hello Eric Gao,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
I understand that you are in need of help for Azure Front Door issue.
Since no response yet from moderator, and actual problem-solving never happened publicly. A 504 in Azure Front Door typically means the origin exceeded the response timeout; this is confirmed when ErrorInfo = OriginTimeout in logs. - https://dori-uw-1.kuma-moon.com/azure/frontdoor/troubleshoot-issues#504-gateway-timeout. However, . Firewall or Network Blocking, SNAT Port Exhaustion (Intermittent Failures), Health Probe Misconfiguration, and TLS / Connection Handshake Issues could be major contributed issue.
The below are the holistic actions you can take to resolve it:
- Check
ErrorInfo, BackendLatency, and TotalLatency to determine whether the delay is backend or network related. - https://dori-uw-1.kuma-moon.com/azure/frontdoor/monitor-front-door
- If
BackendLatency is high, the backend is slow; if near zero, the request never reached the backend successfully. Use log patterns like:
ErrorInfo=OriginTimeout
BackendLatency=0
- Run a direct request to confirm backend responsiveness and isolate AFD from origin issues.
curl -v https://backend-url
- Ensure NSGs, firewalls, and WAF rules allow inbound traffic from AFD infrastructure without silent drops. Reference: https://dori-uw-1.kuma-moon.com/azure/frontdoor/front-door-faq#network-security
- Monitor CPU, memory, and connection limits to detect saturation or thread exhaustion causing slow responses. Reference: https://dori-uw-1.kuma-moon.com/azure/app-service/overview-diagnostics
- Only increase timeout if backend processing legitimately requires more time; do not use it to mask failures. Reference: https://dori-uw-1.kuma-moon.com/azure/frontdoor/front-door-timeout
- Ensure probe path, protocol, and interval correctly reflect backend health to prevent routing to unhealthy instances. Reference: https://dori-uw-1.kuma-moon.com/azure/frontdoor/health-probes
- Verify certificates, DNS resolution, and handshake completion to rule out connection-level failures.
openssl s_client -connect backend-url:443
I hope this is helpful! Do not hesitate to let me know if you have any other questions or clarifications.
Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.