I have a shell script that I use to monitor loading times and response codes on my live server cluster. It runs a total of 250 iterations every 5 minutes, distributed across 10 servers and 6 sites. It uses curl with the -w flag to return pertinent information which is then parsed by my shell script:

curl -svw 'monitor_load_times %{time_total} %{http_code}' -b 'server=$server' -m 15 -o /dev/null $url 2>&1

This information is then parsed by a graphing script that can display a number of different responses. However, curl will occasionally return a response code of "000". When this happens, it seems to happen multiple times at once despite being distributed over many iterations:

Error code graph

What I'm trying to work out is if this is a client-side issue that's skewing my results or if it's actually indicative of a server-side problem affecting my entire cluster. Does 000 mean that the connection was dropped? Database entries corresponding to curl iterations with that response code return "0.000" for the time_total value. All of the search results I've found for curl returning a code of 000 are related to HTTPS being unsupported, but all of my test URLs are HTTP.

(The spike in 500 errors is a completely unrelated issue that affected my servers last night.)

  • 2
    After some more searching, it seems that 000 is intended to indicate that the connection timed out. However, when I see this while running directly from the command line, the curl commands exit almost immediately (more quickly than 200 responses) rather than hanging as you'd expect. Still trying to determine if this issue is client-side or server-side. – Mikkel Dec 7 '12 at 22:59
  • This how a time-out connection looks like: curl -I -w "%{http_code}" https://sitename.com HTTP/1.1 522 Origin Connection Time-out ... – ILIV Apr 7 '16 at 16:48
  • 1
    I was getting 000 when talking to a https server using a http:// url. Seems like it can mean many things. – RobEarl Apr 29 '16 at 15:11

The response 000 indicates that cURL failed to execute for some reason. In such a case, you should test for cURL exit code rather than making assumptions. See the "Exit Codes" section of the curl manpage for a full list of exit codes and their meanings.

Failed DNS resolution (6)

$ curl -w "%{http_code}\n" http://example.invalid/ ; echo "Exit code: $?"
curl: (6) Could not resolve host: example.invalid
Exit code: 6

(As answered by ILIV)

Connection refused (7)

$ curl -w "%{http_code}\n" http://localhost:81/ ; echo "Exit code: $?"
curl: (7) Failed to connect to localhost port 81: Connection refused
Exit code: 7

Connection timed out (28)

$ curl -w "%{http_code}\n" -m 5 ; echo "Exit code: $?"
curl: (28) Connection timed out after 5001 milliseconds
Exit code: 28

(As answered by Arun)

Server actually returns 000 for some reason (0)

Start a fake server:

$ nc -l -p 65535 & <<EOF
> HTTP/1.1 000 Fake Status Code
> Content-Length: 0
> Connection: close

Client request:

$ curl -w "%{http_code}\n" http://localhost:65535/ ; echo "Exit code: $?"
Exit code: 0

No idea why this would happen in the real world, but hey. If cURL doesn't get a valid status code at all, it assumes 200.


I believe 000 means curl failed to resolve a DNS name:

$ curl -I -w "%{http_code}" https://zxcvsitename.com curl: (6) Could not resolve host: zxcvsitename.com; Unknown error 000

Note that it returns this code pretty much immediately.

  • I've changed teams/jobs five times since I encountered this issue and made the post, but this is a perfectly plausible explanation. Thanks! – Mikkel Apr 11 '16 at 20:47
  • 1
    Arun pointed out another possible cause, so I've changed the accepted answer to my own summary of possibilities since I can't accept multiple answers. – Mikkel May 24 '16 at 18:09

Curl 000 means a timeout: - the timeout could be a result of firewall blocking your request from going out. - the timeout could be a result of a connection drop. - The timeout could also be a result of failing to resolve a dns name.

I worked extensively with curl and I pay close attention to all response codes - 000 is one of them. In my cases I received 000 response code when any of the above three conditions were met.

Infact I'm currently running (as I speak) a curl script testing 2000+ uris. Example from my script (hiding ips and domain names):

Response code from <currentip> to http://<domain_name>/category/gifts/category1/category2/12142/ = 200
Response code from <currentip> to http://<domain_name>/category/gifts/category1/category2/12143/ = 000
Response code from <currentip> to http://<domain_name>/category/gifts/category1/category2/12144/ = 000
Response code from <currentip> to http://<domain_name>/category/gifts/category1/category2/12145/ = 200

If you notice above, the domain_name is same for all URLs. While some URLs throw 000, others throw 200, which clearly means it is not a dns issue.

If I go back and hit the individual URL throwing a 000, I usually get a 200. In this case the reason for a 000 is a connectivity issue.

  • It appears to refer to any condition that does not result in an explicit HTTP code being returned, including timeout, connection refused, and DNS resolution failure. I've added an answer that summarizes this and other possible causes. – Mikkel May 24 '16 at 18:10

I had the same issue, http returned 000, but exit code was 0. The reason is the load balancer returned 200, because it could serve the request, but the service behind it wasn't able to.

  • Interesting. From your perspective, what did the raw network traffic look like? – Mikkel Jan 27 at 13:42
  • The app is in AWS EKS, it's a kubernetes pod running an http_server. In front of it sits an ingress (though think it's unrelated here) and an ELB. That is accessible form the outside world and I ran tests from a jenkins job where the slave is technically an EC2. – Adam Bodrogi Jan 28 at 14:48
  • Okay, but I was actually wondering about the request and response between the client and the load balancer, if you intercept it with Wireshark or send raw TCP data with telnet or nc. It seems weird that the load balancer should respond with 200 before receiving a response, not only because it assumes there will be a response, but because it assumes that the response code will be 200. – Mikkel Jan 29 at 15:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.