502 - Bad Gateway error in Order API for Shop

502 - Bad Gateway error in Order API for Shop

ludwig-eisenbl
Shopify Partner
5 0 0

Hi there,

the Shopify LiveChat Support has redirected me to the forums.

 

I keep (randomly) receiving a 502-BadGateway error from the Shopify Order API.

From what I can see this is only occuring for one specific shop we are working with (although the Shopify Status Page does not mention any problems).

 

Is there a Shopify Developer here who can have a look at this?

 

The error happens quite frequently (every 3 or 4 requests) and blocks us from preparing an important accounting export.

 

Thanks!

Replies 13 (13)

hassain
Shopify Staff (Retired)
624 104 188

Hey @ludwig-eisenbl ,

 

We can definitely do our best to help you troubleshoot why this error is happening. Could you please provide the value of the "X-Request-ID" header from your bad API responses? With this value we can search through our logs and better understand why this error is occurring.

 

If I had to make an initial guess as to why you may be receiving that error, usually a 502 error from our API means that you had requested too much information through the API and it caused the SQL query on our end in order to get that data to take too long and eventually time out. So the solution to this would be to request less data through the API request, or adjust the parameters of your request to make the query more efficient. However if you can provide the value of the X-Request-ID header it would help me confirm is my suspicions are true or not

 

 

To learn more visit the Shopify Help Center or the Community Blog.

arsala_halari
New Member
8 0 0

I am having the same issue. All my other sites are downloading just fine however my shopify store is coming with a 502 bad gateway error

 

it is affecting my business we have tried to trouble shoot many things on the shipworks side with no avail.

The same account added to a different computer is also having the same issues so i know it is not only on my computer side. 

 

arsala
arsala_halari
New Member
8 0 0

here is an image 

 

shipworks error.png

arsala
arsala_halari
New Member
8 0 0

This email is a follow up to ticket #36432 regarding the Shopify Downloads. Error we are receiving: 502 Bad Gateway

Steps attempted for fix:
-PC Restart
-Readded app on Shopify backend
-Regenerated Shopify Token
-Tried switching the fulfillment location
-Ran trace routes to api.shopify.com with about a 50% loss
-Tried access Shopify store from different computer
-Found Cloudflare is re-routing California city



Please help us to determine what is causing the issue of Oxford Diamond Co Shopify store's 502 Bad Gateway download error, thank you!

Let us know if you require any additional information, thank you.  

arsala
arsala_halari
New Member
8 0 0

also tried deleting shipworks app and re installing the token

arsala
arsala_halari
New Member
8 0 0

i currently have a ticket open as well

 

Your ticket ID is 14892704.

arsala
BECKYGalbes
Tourist
4 0 1

Same here!whats should I do!!

ludwig-eisenbl
Shopify Partner
5 0 0

Hi Hassain,

thank you for your quick and insightful reply.

Indeed, we are querying the Order API for a very broad set of data including paging for the last 3 months (with the max. number of results == 250).

Thats because we need all this data for an accounting export and it has worked very well for the last 10 months.

 

Unfortunately, we do not log the Shopify response headers on our servers, so I can't provide a Request ID at this time but will try to get one if the error persists. The store where this happens most of the time is "bergmensch.myshopify.com", although I have seen the error for other (Germany) based stores in the meantime.

 

Since our customers need those reports urgently, we have now implemented a retry-mechanism as a fallback strategy. It seems like after the first request the result is available (cached?) and the second request goes through.

Also, yesterday late evening (Berlin time), the requests also succeeded without any errors, so I guess this might be a general server-load issue?

 

Thanks and Best Regards,

Ludwig

hassain
Shopify Staff (Retired)
624 104 188

Hey @ludwig-eisenbl ,

 

Yes, we do cache the results of the query. So even if you timeout and get a 502 the first time, the second time you make the request most of the data will already be cached so you are more likely to get all of the data back without timing out this time. And yes, based on current server/platform load it can effect if your query for data will timeout or not. So the re-try you are performing is good practice. Other good practices for avoiding API timeouts include requesting for less data at one time, and using pagination in your API request (https://help.shopify.com/en/api/guides/paginated-rest-results)

 

Hey @arsala_halari ,

 

I see you have an open Support ticket already with ShipWorks and Shopify support staff, so I am sure they will do their best to help resolve this issue for you

 

To learn more visit the Shopify Help Center or the Community Blog.

Alex502ERROR
Visitor
1 0 1

Hello We are experiencing many error messages and shopify website freezes. We can not see our site no more we are using google chrome and see this message.

its being happening on and off for 4 days already from today's day 7/17/20. What is happening!! where is our live site!

sCapture.PNG

CleanGreen
Visitor
1 0 0

The same thing is happening to us. What fixed it?

Herisson
Visitor
1 0 0

Hello, I manage to solve the problem by following the following pasts.

Step 01: I cleared the entire browser cache and then closed the browser.

Step 02: Now on the keyboard, press the WINDOWS key, hold, and then press the R key and this run window will open, and let's type CMD and you can click ENTER.

Step 03: Now in CMD, it's very simple, let's type IPCONFIG /FLUSHDNS, OK you can click ENTER. Ready the browsing cache has been successfully cleared.

ludwig-eisenbl
Shopify Partner
5 0 0

This issue is coming up from time to time and we fixed it by implementing a retry mechanism for this specific error code (it is not about the regular rate limiting, which can be detected by looking at the headers of the response). I think this occurs either because of the explanation from Shopify support provided in this thread (long running database queries and the proxy server is aborting the web request) or maybe due to load balancing, where the request is routed to a shopify instance which is shut down while processing it (?). Either way, implementing the retry (up to 3 times) solved it for us and none of our customers had that problem anymore.