The remote server returned an error: (502) Bad Gateway


At requesting contact via the api I’m getting this:
Error SendRequest: The remote server returned an error: (502) Bad Gateway.


And now this one:
Error SendRequest: The remote server returned an error: (500) Internal Server Error.


Anyone there?- It’s pretty crusial for me to solve my task!



Is this happening every time?
Can you share with me the full request you are making?


It is not happening all the time but still quite often though.

Here is the reguest:[license key])


…and Contact with vid 1562 does exist!

AND…it’s not always with the same vid that the request fails!


@HenrikJanningJuul Let reach out internally to see if we are having any issues on that are ongoing for our contacts BE servers


Can I expect a feedback with a conclusion on your internal investigation?


@HenrikJanningJuul The team got back to me and don’t have any issues currently with the endpoints or the machines servicing them. There first questions was if you are hitting it very hard and frequently? There are some limits in place so no one portal can consume the entirety of the resources for the endpoint. Also is this happening with just one or two specific vids or is it random each time?


Hi @pmanca

I think I am having this same issue too. My app uses about 10,000 requests a day syncing contacts and companies and I randomly get about 5 internal server error (500) or Bad Gateways (502) a day. I’ve retried the requests that returned errors with same payload and they work fine.

Can you let me know if there’s anything that can be done to stop these errors?



Well, as stephen_c describes we also synchronize Companies and Contacts and because of that sends several thousands requests.- As I have observed it it is with randomly vids.

You mention a limit.- Isn’t this limit at maximum 10 requests a second?


@HenrikJanningJuul @stephen_c

There are general limits as in the secondly limit being 10/calls per second and also 40k total calls/day. There are some other internal limits to prevent one customer from taking completely control of all the resources. for ex. if you make 10 calls/second for 60 minutes long which would result in 36k calls you might start to see internal errors for hitting the API hard for a sustained period of time as opposed to breaking up your 36k calls over a couple hours. If you need to make very large requests very frequently you could always slow down your calls a bit more and see if that helps as opposed to running up against our speed limits for sustained periods of time.


But I intentionally implemented less than 10 calls per second to avoid any problems and at your end you manage to close for any further calls if the 40K limit is being hit so obviously you must have some sort of internal issue with the 500 and 502 error!?


Hey @HenrikJanningJuul,

Just picking this thread back up. Other than the GET request you provided above are you noticing 5XX errors in other requests to the HubSpot API? If we can establish a pattern of this happening it’s possible there’s an error just being disguised as a generic 5XX error. Is your experience similar to @stephen_c where if you retry the request works correctly?

If things are working on retry then it’s just a temporary issue on our end and the solution is to build your app to have retry logic. However we always strive to improve our reliability so if you notice any patterns, like during a specific time of day we can take further action on our end.



I’m not experiencing the issue for the time being but I’m also not calling the api with the same frequency I did before.

But still; if I keep the amount and calls within your limits and the api returns a non desribable error something must be wrong!?



@pmanca I can also confirm this - we see it every other day with the same scenario described, as we gracefully retry if we get a 502, but just so you know this has nothing to do with the Hubspot limits. a 502 is coming back from NGINX where it is taking too long to get a response back from your internal system. If this were a limit imposed by Hubspot, we would get back a much different error. And no, we are nowhere near the calls per second, nor the daily limits. It just doesn’t happen enough for me to complain, but I would say this is something you are already monitoring at layer 5 networking so it won’t be foreign to see.