REST API Errors 520, solved with a proxy


Recently lot of my APIs calls stopped working, for example

I always get weird errors like 520 response code or “cURL error 18: transfer closed with outstanding read data remaining”. And I didn’t change anything, was working all well before…

Can you please investigate on this?

Thanks in advance

how do you make those requests?

if works fine for me now when I test it in web3api interface

It happens randomly I just had the case again with “” => "cURL error 18: transfer closed with outstanding read data remaining "

This one just return 520 bad gateway “

I just do normal requests with Guzzle PHP library and everything was working well but errors suddenly happened recently

I made 50 requests to this url now, I didn’t get any errors, also it doesn’t return data for this particular to_date

This one works well again… The other one still give me an error

@cryptokid This is what I get sometimes when I test within the interface. I never encountered that before this weekend…

Undocumented error…

I tested with this 100 times from a python script and I didn’t get any error

I definitely think there is something going on Moralis servers… these are purely random errors

it could be, how can I replicate that?
what do you do to replicate it?

Hum nothing fancy, I just use the parameters as shown above and try the request a few times. Sometimes work, sometimes not…

I am still not able to replicate it.
someone else seems like also has a similar problem: Deep Index Errors: 520, 502

Yes I saw this one but no solution at the moment because you were not able to replicate as well. If someone else can have a look would be great, I don’t think it’s an isolated case

this is the only endpoint that has this problem?

This works:

This doesn’t:

Maybe it’s something related to response content length. I mostly use logs endpoint but I also get this error while fetching “pair created” event with the rest api

I still get some errors 502 Bad gateway from the Moralis interface itself as follow:

curl -X 'GET' \
  '' \
  -H 'accept: application/json' \
  -H 'X-API-Key

How is that possible?

Did you try to run the requests from another network/IP?

Yes and get the same error from another IP and network

When I debug the interface with the following simple query:

I get this error in my dev console:

Any change in your Nginx config or related to HTTP2 or content length response header recently?

I got this in response as headers:

:status: 200
Content-Type: application/json; charset=utf-8
Access-Control-Allow-Origin: *
Content-Encoding: gzip
ETag: W/"4f78a-qioR7lLRxZrkIRJFzXaMZYwem9k"
Date: Wed, 06 Apr 2022 11:59:07 GMT
Vary: Accept-Encoding
x-rate-limit-limit: 25
x-rate-limit-used: 2
x-powered-by: Express
Server: cloudflare
x-request-weight: 2
cf-cache-status: DYNAMIC
expect-ct: max-age=604800, report-uri=""
x-rate-limit-remaining-ip-ttl: 1
cf-ray: 6f7a5b08db188ce2-EWR
x-rate-limit-remaining-ttl: 1
x-rate-limit-ip-used: 2

what do you do to get that error?

I found a workaround. I created a proxy API to communicate with your API rather than calling it directly and everything looks to work fine again…