axios Network Error (ERR_NETWORK) (tested)

AxiosError: Network Error with code: 'ERR_NETWORK' means the browser gave axios no HTTP response at all. We triggered seven failure types with axios 1.20.0 in Chromium 153. Four different causes produced the exact same error object. Only the DevTools console showed which one it was.

1. What ERR_NETWORK means

In the browser, axios uses XMLHttpRequest. When the request fails before any HTTP response is readable, XHR fires an error event with status 0. axios turns that into message: 'Network Error', code: 'ERR_NETWORK' and error.response === undefined. The browser does not tell JavaScript why. That is on purpose, so pages cannot probe other networks.

2. Our test setup

A Node HTTPS server served a blank page on https://127.0.0.1:8991. We injected axios.min.js into it and called axios.get() against different targets. For each call we logged error.message, error.code, error.response, error.request.status and the console messages Chromium printed.

try {
  await axios.get(url, opts);
} catch (e) {
  console.log(e.message, e.code, e.response?.status, e.request?.status);
}

3. Results in Chromium 153

Causeerror.messageerror.codeerror.responserequest.statusConsole showed
CORS blocked (no Access-Control-Allow-Origin)Network ErrorERR_NETWORKundefined0"...has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource." and net::ERR_FAILED
Connection refused (nothing on the port)Network ErrorERR_NETWORKundefined0net::ERR_CONNECTION_REFUSED
DNS failure (https://nosuchhost.invalid)Network ErrorERR_NETWORKundefined0net::ERR_NAME_NOT_RESOLVED
Mixed content (http:// URL from an https page)Network ErrorERR_NETWORKundefined0"Mixed Content: ... requested an insecure XMLHttpRequest endpoint ... This request has been blocked"
timeout: 500 on a 3 s endpointtimeout of 500ms exceededECONNABORTEDundefined0nothing
Same, with transitional: {clarifyTimeoutError: true}timeout of 500ms exceededETIMEDOUTundefined0nothing
AbortController abort after 300 mscanceledERR_CANCELEDundefined0nothing
Server returns 404 (with CORS header)Request failed with status code 404ERR_BAD_REQUEST404404"Failed to load resource: the server responded with a status of 404 (Not Found)"
Server returns 500 (with CORS header)Request failed with status code 500ERR_BAD_RESPONSE500500"...status of 500 (Internal Server Error)"

Key points:

4. Node.js is more specific

In Node.js 24 axios uses the http module, and the real error code comes through:

Causeerror.messageerror.code
Connection refusedconnect ECONNREFUSED 127.0.0.1:8990ECONNREFUSED
DNS failuregetaddrinfo ENOTFOUND nosuchhost.invalidENOTFOUND

So if the same call works from Node (or curl) but fails in the browser with Network Error, suspect CORS or mixed content first. There is no CORS in Node.

5. How to find the real cause

  1. Open DevTools > Console. The red line next to the failed request names the cause: blocked by CORS policy, Mixed Content, net::ERR_CONNECTION_REFUSED or net::ERR_NAME_NOT_RESOLVED.
  2. Open the Network tab. A CORS failure shows a request that reached the server; refused and DNS failures show no response at all.
  3. Run the same URL with curl from your machine. If curl gets a response, the server is up and the browser is blocking it.

6. Fixes by cause

catch (e) {
  if (axios.isCancel(e)) return;               // ERR_CANCELED
  if (e.response) { /* HTTP error: e.response.status */ }
  else if (e.code === 'ECONNABORTED' || e.code === 'ETIMEDOUT') { /* timeout */ }
  else if (e.code === 'ERR_NETWORK') { /* CORS, offline, DNS, refused, mixed content: check console */ }
}

fetch() has the same problem with a different message. See TypeError: Failed to fetch.

Frequently asked questions

Why does axios say Network Error when the API works in Postman?

Postman and curl do not enforce CORS. In our test a server with no Access-Control-Allow-Origin header gave axios 'Network Error' in Chromium, while the request itself reached the server. Add the CORS header on the API.

Why is error.response undefined?

Because the browser gave axios no readable HTTP response. In all four network-level cases we tested (CORS, refused, DNS, mixed content) error.response was undefined and error.request.status was 0.

Is a timeout a Network Error?

No. With timeout: 500 axios 1.20.0 gave 'timeout of 500ms exceeded' with code ECONNABORTED, or ETIMEDOUT if transitional.clarifyTimeoutError is true.

Can I read the CORS reason from JavaScript?

No. The browser hides it on purpose. It only appears in the DevTools console, for example "No 'Access-Control-Allow-Origin' header is present on the requested resource."

Why do I get ECONNREFUSED in Node but Network Error in the browser?

Node exposes the socket error. In Node 24 axios gave code ECONNREFUSED with message 'connect ECONNREFUSED 127.0.0.1:8990'. The browser only exposes ERR_NETWORK for the same failure.

Written with AI assistance. Measured on 2026-10-02 with axios 1.20.0 (dist/axios.min.js) in headless Chromium 153 via Playwright, against a local HTTPS Node server, and axios 1.20.0 in Node.js 24.21.0. PlainHeaders is our extension; axios, Chromium and Node.js are free.