Invalid response in a curl request

Due to posting limits, please refer “website” as “https://pant.family” in the description below:

Error Message

While executing a curl on my website, I get the following error and empty content

(base) ypant@shiv pantfamily % curl
(base) ypant@shiv pantfamily % dig

; <<>> DiG 9.10.6 <<>> website
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 52924
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;pant.family. IN A

;; ANSWER SECTION:
pant.family. 185 IN A 172.67.209.43
pant.family. 185 IN A 104.21.37.143

;; Query time: 40 msec
;; SERVER: fe80::ca99:b2ff:fee2:d36b%12#53(fe80::ca99:b2ff:fee2:d36b%12)
;; WHEN: Sun Jul 09 08:08:39 CDT 2023
;; MSG SIZE rcvd: 72

% curl
<< no response or empty here >>

% curl -I https://pant.family

HTTP/2 520
date: Sun, 09 Jul 2023 13:09:30 GMT
content-length: 0
cache-control: no-store, no-cache
cf-cache-status: DYNAMIC
report-to: {“endpoints”:[{“url”:“https://a.nel.cloudflare.com/report/v3?s=jsySghlYwns%2B6KO9w7eHiVhdn7IZ9XRBYhM9Jilwz2eut4Lwcu0B3YcvfX5oT%2FL8S9cOELkr2izA%2FELluWnI%2BNQ%2FyjmkBHkTmlTZkxhoqQ8%2FtkNXnN%2Fu5kZXapynhaN8usrUGJZD4efflA%3D%3D”}],“group”:“cf-nel”,“max_age”:604800}
nel: {“success_fraction”:0,“report_to”:“cf-nel”,“max_age”:604800}

server: cloudflare
cf-ray: 7e40cd406e02806c-ORD
alt-svc: h3=“:443”; ma=86400

Other Information

Its using a custom domain that uses cloudflare name servers. Using infinityfree name server gives the following error:

% curl
curl: (92) HTTP/2 stream 1 was not closed cleanly: PROTOCOL_ERROR (err 1)

Here is the information with regard to 520 error (as reported by CloudFlare):

"Error 520 is a Cloudflare error message indicating that the origin web server received an invalid or incorrectly interpreted request, resulting in an empty response. "

(other information and details relevant to your question)

I believe this is what had happened.

Curl command does not work well on free hosting.
If url has not been loaded before, you will encounter an error.
Once url is loaded on browser, CloudFlare will save a copy of it as cache.
So long this cache is not emptied, the curl command will continue to work

4 Likes

All that I see in the long command output is that you are using Cloudflare and Clouflare said your site is down.

The weird thing is that when I try to access your site with cURL, I also get the 520 error. But when I try to open it in a browser, I get a redirection loop error.

In the Network tab, I see that these redirects have the header x-redirect-by: WordPress. And WordPress and Cloudflare don’t work together out of the box, because WordPress doesn’t handle HTTPS properly when using Flexible SSL.

The recommend way to fix this is to use Full SSL instead, which is pretty sure and pretty easy to setup:

Alternatively, if you’d rather use Flexible SSL, this is how you can make it work with WordPress:

I’m confident that doing this will fix your website. What will happen to the cURL result, I don’t know, but I’m guessing that will work too.

7 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.