ajaxhttpxmlhttprequesthttpresponsefetch-api

What does it mean when an HTTP request returns status code 0?


What does it mean when JavaScript network calls such as fetch or XMLHttpRequest, or any other type of HTTP network request, fail with an HTTP status code of 0?

This doesn't seem to be a valid HTTP status code as other codes are three digits in HTTP specification.

I tried unplugging the network completely as a test. It may be unrelated, but that resulted in status code 17003 (IIRC), which cursory searching suggests means "DNS server lookup failed".

The same code works fine from some locations and systems, however within certain environments it fails with status code 0 and there is no responseText provided.

This is a typical HTTP POST to an Internet URL. It does not involve file:// which I understand may return 0 indicating success in Firefox.


Solution

  • I believe the error code indicates that the response was empty, (as not even headers were returned). This means the connection was accepted and then closed gracefully (TCP FIN). There are a number of things which could cause this, but based off of your description, some form of firewall seems the most likely culprit.