# 502 Proxy Error again

**URL:** <https://ask.openrouteservice.org/t/502-proxy-error-again/1894>\
**Category:** QGIS\
**Created:** [July 7, 2020, 2:16pm UTC](https://ask.openrouteservice.org/t/502-proxy-error-again/1894 "2020-07-07T14:16:32Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![gwfami2](https://ask.openrouteservice.org/letter_avatar_proxy/v4/letter/g/f17d59/32.png) [@gwfami2](https://ask.openrouteservice.org/u/gwfami2)\
**Post date:** [July 7, 2020, 2:16pm UTC](https://ask.openrouteservice.org/t/502-proxy-error-again/1894/1 "2020-07-07T14:16:32Z")

</div>

I’m experiencing the dreaded 502 error and I have not been able to get past it regardless of the number of locations. Tried it at all hours of the day in case there was a server overload. Even tried it using the openroute API playground, and get another type of error. I know the key is good, as I’ve been able to use it to do different things.

I’m completely out of ideas.

Here’s the curl post and the response.

curl -X POST ‘[https://api.openrouteservice.org/v2/isochrones/driving-car](https://api.openrouteservice.org/v2/isochrones/driving-car)’ -H ‘Content-Type: application/json; charset=utf-8’ -H ‘Accept: application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8’ -H 'Authorization: ’ -d ‘{“locations”:[[-96.2611607,38.979813],[-100.112218,39.3742674]],“range”:[300,260],“interval”:10,“range\_type”:“distance”,“area\_units”:“mi”,“units”:“mi”}’

502 Proxy Error
# Proxy Error

The proxy server received an invalid response from an upstream server.  
The proxy server could not handle the request

Reason: **Error reading from remote server**

Here’s the playground api request and it’s return.

```auto
curl -X POST \
  'https://api.openrouteservice.org/v2/isochrones/driving-car' \
  -H 'Content-Type: application/json; charset=utf-8' \
  -H 'Accept: application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8' \
  -H 'Authorization: ' \
  -d '{"locations":[[-96.2611607,38.979813],[-100.112218,39.3742674]],"range":[300,200],"interval":10,"range_type":"distance","area_units":"mi","units":"mi"}'

```

Invalid API key or access to this API has been disallowed

---

<div class="post-metadata">

**Author:** ![adam](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/adam/32/8_2.png) [@adam](https://ask.openrouteservice.org/u/adam)\
**Post date:** [July 7, 2020, 2:26pm UTC](https://ask.openrouteservice.org/t/502-proxy-error-again/1894/2 "2020-07-07T14:26:06Z")

</div>

Are you passing in your API key with your request? (`https://api.openrouteservice.org/v2/isochrones/driving-car?api_key=xxx`)

---

<div class="post-metadata">

**Author:** ![adam](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/adam/32/8_2.png) [@adam](https://ask.openrouteservice.org/u/adam)\
**Post date:** [July 7, 2020, 2:29pm UTC](https://ask.openrouteservice.org/t/502-proxy-error-again/1894/3 "2020-07-07T14:29:49Z")

</div>

Actually, I see you are using the authorisation header… maybe try it with the api\_key in the url method and see if that fixes it as maybe if you are going through a proxy it is stripping off the authorisation header

---

<div class="post-metadata">

**Author:** ![gwfami2](https://ask.openrouteservice.org/letter_avatar_proxy/v4/letter/g/f17d59/32.png) [@gwfami2](https://ask.openrouteservice.org/u/gwfami2)\
**Post date:** [July 7, 2020, 8:39pm UTC](https://ask.openrouteservice.org/t/502-proxy-error-again/1894/4 "2020-07-07T20:39:28Z")

</div>

Yes, I’m passing the API key, using the ‘Authorization’ header, just removed it so that it wasn’t public.

I used the api\_key method, and it returned this.

{  
“error”: “Authorization field/api\_key missing in request. If you do not have a token, please sign up for one at [https://openrouteservice.org](https://openrouteservice.org)”  
}

I also just looked at the response headers, and it appears that the system thinks I have reached my limit. However, I haven’t ran 500 requests in the last 24 hours so I’m not sure what to think.

HTTP/1.1 502 Bad Gateway  
Server: nginx/1.10.3 (Ubuntu)  
Date: Tue, 07 Jul 2020 20:34:37 GMT  
Content-Type: text/html; charset=iso-8859-1  
Content-Length: 341  
Connection: keep-alive  
X-Ratelimit-Limit: 500  
X-Ratelimit-Remaining: 0  
X-Ratelimit-Reset: 0

---

<div class="post-metadata">

**Author:** ![adam](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/adam/32/8_2.png) [@adam](https://ask.openrouteservice.org/u/adam)\
**Post date:** [July 8, 2020, 6:18am UTC](https://ask.openrouteservice.org/t/502-proxy-error-again/1894/5 "2020-07-08T06:18:15Z")

</div>

Yeh, the reporting of rate limits are a bit funny sometimes and don’t always show the correct figure. If you send your API key and the full request you are using to [enquiry@openrouteservice.org](mailto:enquiry@openrouteservice.org) I can have a look and see if there is an issue with the key

---

<div class="post-metadata">

**Author:** ![gwfami2](https://ask.openrouteservice.org/letter_avatar_proxy/v4/letter/g/f17d59/32.png) [@gwfami2](https://ask.openrouteservice.org/u/gwfami2)\
**Post date:** [July 8, 2020, 9:23pm UTC](https://ask.openrouteservice.org/t/502-proxy-error-again/1894/6 "2020-07-08T21:23:47Z")

</div>

Seems to be working now for the most part. I’ll hold off until I can recreate the issue.  
Thanks.

---

<div class="post-metadata">

**Author:** ![Gijs](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/gijs/32/664_2.png) [@Gijs](https://ask.openrouteservice.org/u/Gijs)\
**Post date:** [July 21, 2020, 1:38pm UTC](https://ask.openrouteservice.org/t/502-proxy-error-again/1894/7 "2020-07-21T13:38:01Z")

</div>

I’ve been having these errors intermittently today. While request size seems to play a role, I also seem to have found a solution.

I’m requesting some matrices (few to many) that are just below the rate limit of 2500 connections/request. These large request fail more often than not, but not consistently. I played around with other request (smaller size or different endpoint) and encountered no problem at all.

Somehow switching the destinations and sources also seemed to fix the issue. So instead of a ‘many to few’ matrix I requested a ‘few to many’ matrix. (And then of course adjusted how I handled the returns.) And there were no more issues. I fail to see how this is different in workload for the server but I hope this helps you and others.

edit: Forgot to thank you guys for this great service. It is absolutely wonderful for my thesis research.

---

<div class="post-metadata">

**Author:** ![adam](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/adam/32/8_2.png) [@adam](https://ask.openrouteservice.org/u/adam)\
**Post date:** [July 23, 2020, 9:29am UTC](https://ask.openrouteservice.org/t/502-proxy-error-again/1894/8 "2020-07-23T09:29:37Z")

</div>

Hmm, yes that does sound strange that reversing makes the issue go away. Maybe @HendrikLeuschner would know why as he is our “go to” Matrix guy

And glad that openrouteservice is being useful for your research 🙂

---

<div class="post-metadata">

**Author:** ![HendrikLeuschner](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/hendrikleuschner/32/509_2.png) [@HendrikLeuschner](https://ask.openrouteservice.org/u/HendrikLeuschner)\
**Post date:** [July 23, 2020, 9:44am UTC](https://ask.openrouteservice.org/t/502-proxy-error-again/1894/9 "2020-07-23T09:44:13Z")

</div>

Matrix actually runs better with few to many than with many to few. This is due to our current design (could use a rework, wouldnt even be a lot of work). Whats the error you’re getting? 502 proxy error?

---

<div class="post-metadata">

**Author:** ![Gijs](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/gijs/32/664_2.png) [@Gijs](https://ask.openrouteservice.org/u/Gijs)\
**Post date:** [July 23, 2020, 10:00am UTC](https://ask.openrouteservice.org/t/502-proxy-error-again/1894/10 "2020-07-23T10:00:37Z")

</div>

I received a ‘Bad Gateway (HTTP 502)’ so not the 502 proxy error. I just latched on to this thread after searching for ‘502’ 😅 My bad.  
Still, the error didn’t consistently appear. Only during parts of the day (European late mornings and early afternoons) and only for requests with many origins. It therefor seems like a server load issue to me. Changing from ‘many to few’ to ‘few to many’ completely solved it for me.

---

<div class="post-metadata">

**Author:** ![HendrikLeuschner](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/hendrikleuschner/32/509_2.png) [@HendrikLeuschner](https://ask.openrouteservice.org/u/HendrikLeuschner)\
**Post date:** [July 23, 2020, 11:39am UTC](https://ask.openrouteservice.org/t/502-proxy-error-again/1894/11 "2020-07-23T11:39:29Z")

</div>

Alright, great. If you have any other problems, please open separate issues for them here. We will look into making the matrix better with many to few
