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
| Cause | error.message | error.code | error.response | request.status | Console showed |
|---|---|---|---|---|---|
| CORS blocked (no Access-Control-Allow-Origin) | Network Error | ERR_NETWORK | undefined | 0 | "...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 Error | ERR_NETWORK | undefined | 0 | net::ERR_CONNECTION_REFUSED |
| DNS failure (https://nosuchhost.invalid) | Network Error | ERR_NETWORK | undefined | 0 | net::ERR_NAME_NOT_RESOLVED |
| Mixed content (http:// URL from an https page) | Network Error | ERR_NETWORK | undefined | 0 | "Mixed Content: ... requested an insecure XMLHttpRequest endpoint ... This request has been blocked" |
timeout: 500 on a 3 s endpoint | timeout of 500ms exceeded | ECONNABORTED | undefined | 0 | nothing |
Same, with transitional: {clarifyTimeoutError: true} | timeout of 500ms exceeded | ETIMEDOUT | undefined | 0 | nothing |
| AbortController abort after 300 ms | canceled | ERR_CANCELED | undefined | 0 | nothing |
| Server returns 404 (with CORS header) | Request failed with status code 404 | ERR_BAD_REQUEST | 404 | 404 | "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 500 | ERR_BAD_RESPONSE | 500 | 500 | "...status of 500 (Internal Server Error)" |
Key points:
- The first four rows are identical in JavaScript. You cannot tell CORS from a down server from a typo in the host name by looking at the error object.
- A timeout is not
ERR_NETWORK. By default it isECONNABORTED; the abort isERR_CANCELEDwitherror.name === 'CanceledError'andaxios.isCancel(e) === true. - 4xx gives
ERR_BAD_REQUESTand 5xx givesERR_BAD_RESPONSE, both with a realerror.response. If you see a response, it is not a network error. - Mixed content is checked before DNS. Our first DNS test used an
http://host from the https page and Chromium reported mixed content, not a DNS failure.
4. Node.js is more specific
In Node.js 24 axios uses the http module, and the real error code comes through:
| Cause | error.message | error.code |
|---|---|---|
| Connection refused | connect ECONNREFUSED 127.0.0.1:8990 | ECONNREFUSED |
| DNS failure | getaddrinfo ENOTFOUND nosuchhost.invalid | ENOTFOUND |
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
- Open DevTools > Console. The red line next to the failed request names the cause:
blocked by CORS policy,Mixed Content,net::ERR_CONNECTION_REFUSEDornet::ERR_NAME_NOT_RESOLVED. - Open the Network tab. A CORS failure shows a request that reached the server; refused and DNS failures show no response at all.
- 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
- CORS: the API must send
Access-Control-Allow-Originfor your page origin (and handle the preflight if you send JSON or custom headers). See CORS error messages explained. Changing axios settings cannot fix this. - Connection refused: the server is not listening on that host and port. Check the base URL, the port, and that the server binds to the right interface. See ERR_CONNECTION_REFUSED / ECONNREFUSED.
- DNS failure: fix the host name in
baseURLor the DNS record. - Mixed content: use
https://for the API, or a relative URL. See mixed content blocked. - Timeouts: handle
ECONNABORTED(orETIMEDOUTwithclarifyTimeoutError) separately fromERR_NETWORK.
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.