Quick Answer
- The root cause is an automatic service container restart — during the restart window the web console is unreachable and the API returns 502; they are the same event.
- Recovery is usually automatic within 1 minute — wait 30-60 seconds and resend your request.
- Failed calls are never billed — during a 502 the request never actually reaches the service, so no billing record is created.
- Add automatic retries on the client side — a single retry after about 30 seconds rides out the entire restart window seamlessly.
What Is Happening
502 Bad Gateway means: the gateway layer received your request but got no response when forwarding it to the backend service.
On APIYI, the vast majority of transient 502s are caused by an automatic restart of the backend service container. While the backend process is briefly unavailable:
- The web console (dashboard, top-up pages, etc.) fails to load or shows errors
- The API (
api.apiyi.comand all other endpoints) returns 502
What You Should Do
Step 1: Wait 30-60 seconds, then resend the request
Step 2: If the web console won't load, force-refresh the page
Step 3: If the 502 persists for more than 5 minutes, contact support
14:30 (UTC+8)).Adding Automatic Retries to Programmatic Calls
If your workload is availability-sensitive, add automatic retries for transient errors like 502 on the client side — one retry after about 30 seconds covers the entire restart window.- Python
- Node.js
- cURL
Frequently Asked Questions
Are requests made during a 502 billed?
Are requests made during a 502 billed?
How is a 502 different from a timeout, 429, or 524?
How is a 502 different from a timeout, 429, or 524?
502: The backend service is briefly unavailable (container restarting). Wait 30-60 seconds and retry; not billed.- Timeout / dropped connection: Your client timeout is too short — the server may still be running the request and billing it normally. See How to Avoid API Timeouts.
429: Concurrency or rate limit reached; unrelated to service availability. See API Concurrency Limits.524: You are on the CDN endpoint (api-cf.apiyi.com) with a request exceeding roughly 100 seconds — switch endpoints.
Why do the web console and the API fail at the same time?
Why do the web console and the API fail at the same time?
Will this happen often?
Will this happen often?
How do I tell whether it's a platform issue or my own network?
How do I tell whether it's a platform issue or my own network?
- Open the web console: if
api.apiyi.comreturns 502 and the console also fails to load, it is almost certainly a transient platform-side restart — wait a minute. - Switch networks: try mobile data (a different carrier) to load the console, or run the command below. If it works there, the problem is your local network or proxy.
Related Documentation
How to Avoid API Timeouts
Do I Need a Proxy to Use the API?
Where Are APIYI's Servers?
Service Availability and SLA
Contact Us
WeCom Support
