520: Web server is returning an unknown error via API call


#1

Hi you guys,

I’m facing the issue:

After my end-user verifies their payment information, the code will call an API server to send an order information to them.

But when the code call the API, I got an error:

520: Web server is returning an unknown error

Below is the full error with CF-RAY

There is an unknown connection issue between Cloudflare and the origin web server. As a result, the web page can not be displayed.</p></div>

<div class=\"cf-colum" <> ..., headers: [{"Date", "Tue, 12 Dec 2017 05:15:45 GMT"}, {"Content-Type", "text/html; charset=UTF-8"}, {"Transfer-Encoding", "chunked"}, {"Connection", "keep-alive"}, {"Set-Cookie", "__cfduid=d26f80d8e12926938401d9319ce2585941513055745; expires=Wed, 12-Dec-18 05:15:45 GMT; path=/; domain=.siliconjungles.com; HttpOnly; Secure"}, {"Expires", "Thu, 01 Jan 1970 00:00:01 GMT"}, 

{"Cache-Control", "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"}, {"Pragma", "no-cache"}, {"X-Frame-Options", "SAMEORIGIN"}, {"Set-Cookie", "cf_use_ob=443; expires=Tue, 12-Dec-17 05:16:15 GMT; path=/"}, {"Set-Cookie", "cf_ob_info=520:3cbe352c1b6232cb:HKG; expires=Tue, 12-Dec-17 05:16:15 GMT; path=/"},

{"Server", "cloudflare-nginx"}, {"CF-RAY", "3cbe352c1b6232cb-HKG"}], request_url: "xxxx", status_code: 520}

My application is built by Phoenix framework and the API server is built by Ruby on Rails framework.

Both servers are deployed to AliCloud - Hong-Kong region. I have checked the API server, and it doesn’t receive any request from my Phoenix server cause Cloudflare stop it.

Could you guys help me check the problem?

Thanks in advance.


#2

Looks to be an issue on the API side of things.
“520 errors are generally caused at Layer 7, which is the Application Layer. This means that a 520 error is the result of a bad response coming back from the application. Rate limiting, or filtering requests (e.g. by connecting IP, or volume/frequency) can sometime cause issues with your application.”

To diagnose this, try to hit the api server directly instead of through cloudflare. That may show the error more clearly for you to fix it.


#3

Thanks for your reply.

I tried. This error will occur sometime, normally when we deploy new code to servers.

I don’t think the cause from the API server. If I make a request from browser, I can receive the response from API server, but if I curl from Phoenix server, I can’t.

Here is the error from Cloudflare when I try to curl the API server.

There is an issue between Cloudflare's cache and your origin web server. Cloudflare monitors for 
these errors and automatically investigates the cause. To help support the investigation, you can
 pull the corresponding error log from your web server and submit it our support team. 
 Please include the Ray ID (which is at the bottom of this error page)

And my Cloudflare Ray ID: 3cff6c148eb43283

Could you guys help me check it

Thanks,


#4

Then I’d say investigate the Phoenix server.