# Code 502 from server

**URL:** <https://community.shiphero.com/t/code-502-from-server/228>\
**Category:** GraphQL API\
**Created:** [November 12, 2019, 12:43pm UTC](https://community.shiphero.com/t/code-502-from-server/228 "2019-11-12T12:43:18Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeremyw](https://avatars.discourse-cdn.com/v4/letter/j/3da27b/32.png) [@jeremyw](https://community.shiphero.com/u/jeremyw)\
**Post date:** [November 12, 2019, 12:43pm UTC](https://community.shiphero.com/t/code-502-from-server/228/1 "2019-11-12T12:43:18Z")

</div>

Hello,

Periodically when sending a query to the API, the Python requests library gets back a response code of 502. It’s basically a total failure when trying to send the query as there’s no data that actually comes back from the API, and therefore no request\_id to reference.

Often times this will happen when the script is paginating through the long results set of a query. For example, I have one that uses the picks\_per\_day query and gets everything from the previous working day. In total there may be around 2000 records to download, and it will be going fine and then all of a sudden around the 8th page, for example, it will throw the 502 error. If I rerun the script, t will work fine. It’s like there’s a momentary hiccup in the API server and then it works again, but it’s enough to throw off the script.

So I guess my question is what is causing this 502 error, and is there any simple way around it?

Thanks,  
Jeremy

---

<div class="post-metadata">

**Author:** ![jeremyw](https://avatars.discourse-cdn.com/v4/letter/j/3da27b/32.png) [@jeremyw](https://community.shiphero.com/u/jeremyw)\
**Post date:** [November 14, 2019, 2:43pm UTC](https://community.shiphero.com/t/code-502-from-server/228/2 "2019-11-14T14:43:18Z")

</div>

Just a bump. I got this again this morning. Can anyone give any insight?

Thanks.

---

<div class="post-metadata">

**Author:** ![mpspw](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@mpspw](https://community.shiphero.com/u/mpspw)\
**Post date:** [November 18, 2019, 5:17pm UTC](https://community.shiphero.com/t/code-502-from-server/228/3 "2019-11-18T17:17:47Z")

</div>

Bump. Having the same issue while fetching product data. In my case it’s happening very often. Sometimes even when fetching the 1st page.

---

<div class="post-metadata">

**Author:** ![seba](https://avatars.discourse-cdn.com/v4/letter/s/50afbb/32.png) [@seba](https://community.shiphero.com/u/seba)\
**Post date:** [November 18, 2019, 5:25pm UTC](https://community.shiphero.com/t/code-502-from-server/228/4 "2019-11-18T17:25:24Z")

</div>

Hi guys, sorry for the delay. @jeremyw this has been happening on the picks query only? could you share the query please?  
@mpspw could you please share the query? is it only with products?

thanks!

---

<div class="post-metadata">

**Author:** ![jeremyw](https://avatars.discourse-cdn.com/v4/letter/j/3da27b/32.png) [@jeremyw](https://community.shiphero.com/u/jeremyw)\
**Post date:** [November 18, 2019, 5:40pm UTC](https://community.shiphero.com/t/code-502-from-server/228/5 "2019-11-18T17:40:38Z")

</div>

Hi Seba,

The direct answer to your question is “yes”, I’ve only seen it happening on the picks\_per\_day query, but then again, it’s the only query where I’m actively monitoring the results. So, it could be happening elsewhere and I just haven’t seen it yet. Considering that mpspw has been seeing something similar on the products query, I’m guessing it’s not limited to picks\_per\_day.

My query is as follows:

```
query($timestamp: ISODateTime, $cursor: String, $record_count: Int) {
    picks_per_day(date_from: $timestamp) {
        request_id
        complexity
        data(after: $cursor, first: $record_count, sort: "created_at") {
            pageInfo {
                hasPreviousPage
                hasNextPage
                endCursor
            }
            edges {
                cursor
                node {
                    id
                    user_first_name
                    user_last_name
                    order_number
                    sku
                    picked_quantity
                    inventory_bin
                    barcode_scanned
                    created_at
                }
            }
        }
    }
}

```

Thanks!

---

<div class="post-metadata">

**Author:** ![mpspw](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@mpspw](https://community.shiphero.com/u/mpspw)\
**Post date:** [November 19, 2019, 10:25am UTC](https://community.shiphero.com/t/code-502-from-server/228/6 "2019-11-19T10:25:55Z")

</div>

Hi @seba It happens randomly, even when trying to acquire the access token or when refreshing token. I noticed it more on the product/products as these are the ones i have been messing around the most with lately.  
Below are two example queries that returned said error.  
Product:

> query {  
> product(sku: “TESTPRODUCT”) {  
> complexity  
> request\_id  
> data {  
> id  
> legacy\_id  
> name  
> sku  
> barcode  
> country\_of\_manufacture  
> dimensions {  
> weight  
> height  
> width  
> length  
> }  
> tariff\_code  
> kit  
> kit  
> no\_air  
> final\_sale  
> customs\_value  
> customs\_description  
> not\_owned  
> dropship  
> needs\_serial\_number  
> thumbnail  
> large\_thumbnail  
> created\_at  
> updated\_at  
> warehouse\_products {  
> id  
> warehouse\_id  
> on\_hand  
> }  
> images {  
> src  
> position  
> }  
> tags  
> vendors {  
> vendor\_id  
> vendor\_sku  
> }  
> components {  
> id  
> }  
> }  
> }  
> }

Products:

> query {  
> products {  
> complexity,  
> request\_id  
> data(first:100, after:“YXJyYXljb25uZWN0aW9uOjk5”,) {  
> pageInfo {  
> startCursor,  
> endCursor,  
> hasNextPage,  
> hasPreviousPage  
> }  
> edges {  
> cursor  
> node {  
> id,  
> legacy\_id,  
> name,  
> sku,  
> barcode,  
> country\_of\_manufacture,  
> dimensions {  
> weight,  
> height,  
> width,  
> length  
> }  
> tariff\_code,  
> kit,  
> no\_air,  
> final\_sale,  
> customs\_value,  
> customs\_description,  
> not\_owned,  
> dropship,  
> needs\_serial\_number,  
> thumbnail,  
> large\_thumbnail,  
> created\_at,  
> updated\_at,  
> warehouse\_products {  
> id,  
> warehouse\_id,  
> on\_hand  
> }  
> images {  
> src,  
> position  
> }  
> tags,  
> vendors {  
> vendor\_id,  
> vendor\_sku  
> }  
> components {  
> id,  
> sku  
> }  
> }  
> }  
> }  
> }  
> }

I also noticed it happening when fetching the schema when using Insomnia GraphQL client (as seen in the image below).  
 ![Screenshot%20from%202019-11-19%2008-55-54](https://us1.discourse-cdn.com/flex020/uploads/shiphero/original/1X/6fbc4285cf77d855a0850796d65bccbbf72c60f5.png)

---

<div class="post-metadata">

**Author:** ![seba](https://avatars.discourse-cdn.com/v4/letter/s/50afbb/32.png) [@seba](https://community.shiphero.com/u/seba)\
**Post date:** [November 20, 2019, 2:07pm UTC](https://community.shiphero.com/t/code-502-from-server/228/7 "2019-11-20T14:07:35Z")

</div>

We are looking into it, will keep you posted. Please let us know if you keep experiencing this 502 or if you stop getting those. Thanks!

---

<div class="post-metadata">

**Author:** ![mpspw](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@mpspw](https://community.shiphero.com/u/mpspw)\
**Post date:** [November 21, 2019, 11:44am UTC](https://community.shiphero.com/t/code-502-from-server/228/8 "2019-11-21T11:44:55Z")

</div>

@seba Just letting you know that the error keeps happening randomly but often for me, no matter if i’m fetching Shiphero data through code or if i’m just using the GraphQL client (when getting the schema also, as mentioned in my previous post).

---

<div class="post-metadata">

**Author:** ![jeremyw](https://avatars.discourse-cdn.com/v4/letter/j/3da27b/32.png) [@jeremyw](https://community.shiphero.com/u/jeremyw)\
**Post date:** [November 29, 2019, 12:28pm UTC](https://community.shiphero.com/t/code-502-from-server/228/9 "2019-11-29T12:28:12Z")

</div>

Good morning, @seba!

This morning around 7:24am EST, Nov 29, I received another 502 error.

![35%20AM](https://us1.discourse-cdn.com/flex020/uploads/shiphero/original/1X/9dd2408503a04de5a2c3b2314b9a02aa6a16104c.png)

---

<div class="post-metadata">

**Author:** ![jeremyw](https://avatars.discourse-cdn.com/v4/letter/j/3da27b/32.png) [@jeremyw](https://community.shiphero.com/u/jeremyw)\
**Post date:** [December 3, 2019, 12:12pm UTC](https://community.shiphero.com/t/code-502-from-server/228/10 "2019-12-03T12:12:48Z")

</div>

Good morning, @seba!

This morning around 7am EST, Dec 3, I got another 502 error. It looks exactly the same as above. It came up after successfully pulling down 4400 picks. And I forgot to mention the other day it had pulled 5000 picks before giving the error.

Thanks,  
Jeremy

---

<div class="post-metadata">

**Author:** ![seba](https://avatars.discourse-cdn.com/v4/letter/s/50afbb/32.png) [@seba](https://community.shiphero.com/u/seba)\
**Post date:** [December 3, 2019, 12:21pm UTC](https://community.shiphero.com/t/code-502-from-server/228/11 "2019-12-03T12:21:42Z")

</div>

Thanks guys, we are looking at the issue, it doesn’t seem to happen that often but we do have so possible improvements that we are going to try (have been busy with BF/CM). Will keep you posted.

---

<div class="post-metadata">

**Author:** ![sHelme](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@sHelme](https://community.shiphero.com/u/sHelme)\
**Post date:** [December 19, 2019, 3:43pm UTC](https://community.shiphero.com/t/code-502-from-server/228/12 "2019-12-19T15:43:53Z")

</div>

Hello @seba,

we’re also getting this issue from seemingly at random while checking inventory. Since we’re paginating here this can break the entire call. Unfortunately I’m unable to set up retrys with our current system.  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/shiphero/original/1X/780d56840a72595df68d2fbfb2e97cd28efc3d2c.png)  
Could you please give us a status update on the issue?

Best  
Stefan

---

<div class="post-metadata">

**Author:** ![jeremyw](https://avatars.discourse-cdn.com/v4/letter/j/3da27b/32.png) [@jeremyw](https://community.shiphero.com/u/jeremyw)\
**Post date:** [January 14, 2020, 11:56am UTC](https://community.shiphero.com/t/code-502-from-server/228/13 "2020-01-14T11:56:46Z")

</div>

Hi @seba,

I’m still seeing this issue, and this morning I even got a 504 Gateway Timeout error instead of a 502. Do you know if there’s been any update on this?

Thanks,  
Jeremy

---

<div class="post-metadata">

**Author:** ![statonjm](https://avatars.discourse-cdn.com/v4/letter/s/d78d45/32.png) [@statonjm](https://community.shiphero.com/u/statonjm)\
**Post date:** [January 21, 2020, 11:05pm UTC](https://community.shiphero.com/t/code-502-from-server/228/14 "2020-01-21T23:05:58Z")

</div>

Joining in on this - I seem to get the same 502 error frequently as well. It might be as much as 5% or more of calls I make.

I’ve come up with a workaround if you run into this while paginating. While looping through the pages, if it returns a 502 status code, just repeat the exact same request again. I made my call function very modular, so if response = 502 then call the same function passing the same parameters into it. If it is a success, then pass along next page info!

It is a bit of custom code, but I’ve found it good to use for almost any integration, as 502s can sporadically appear and shouldn’t disrupt you!

---

<div class="post-metadata">

**Author:** ![david](https://sea2.discourse-cdn.com/flex020/user_avatar/community.shiphero.com/david/32/22_2.png) [@david](https://community.shiphero.com/u/david)\
**Post date:** [March 12, 2020, 11:53pm UTC](https://community.shiphero.com/t/code-502-from-server/228/15 "2020-03-12T23:53:13Z")

</div>

Just to chime in as well, I am continuing to see 502 errors periodically (periodically is daily, but the majority of calls are successful).

Most of these are seen an product queries.

Qualitatively, these seems to happen the most when we make a large consecutive series of calls.

---

<div class="post-metadata">

**Author:** ![originsid](https://avatars.discourse-cdn.com/v4/letter/o/cc9497/32.png) [@originsid](https://community.shiphero.com/u/originsid)\
**Post date:** [March 13, 2020, 12:21am UTC](https://community.shiphero.com/t/code-502-from-server/228/16 "2020-03-13T00:21:21Z")

</div>

![image](https://us1.discourse-cdn.com/flex020/uploads/shiphero/original/1X/eb4e01c49777e11ebd01e092884f3d231e8f3bce.png)

Hey All, Like this?

I get it when paginating orders and when paginating line items for those orders.

I’ve compensated by retrying after a reasonable amount of time and it hasn’t failed again after that interval yet, but it does add some complexity. Errors can happen with any service but they do happen pretty regularly when making a consecutive series of calls like @david says. Products for him, orders/line items for me, and picks per day for @jeremyw.

---

<div class="post-metadata">

**Author:** ![david](https://sea2.discourse-cdn.com/flex020/user_avatar/community.shiphero.com/david/32/22_2.png) [@david](https://community.shiphero.com/u/david)\
**Post date:** [April 3, 2020, 12:25pm UTC](https://community.shiphero.com/t/code-502-from-server/228/17 "2020-04-03T12:25:01Z")

</div>

> [@seba](#):
>
> Thanks guys, we are looking at the issue, it doesn’t seem to happen that often

It has been approximately 3 months. Are there any updates?

Regarding “it doesn’t seem to happen that often”… it happens multiple times per day.

---

<div class="post-metadata">

**Author:** ![seba](https://avatars.discourse-cdn.com/v4/letter/s/50afbb/32.png) [@seba](https://community.shiphero.com/u/seba)\
**Post date:** [April 3, 2020, 1:12pm UTC](https://community.shiphero.com/t/code-502-from-server/228/18 "2020-04-03T13:12:25Z")

</div>

Sorry for the inconvenience, our devops team is working on this as we speak. We will probably have some news in a couple of weeks, so we will keep you posted.
