---
title: "Fix AxiosError Network Error and find which of its 3 causes you have"
description: "AxiosError: Network Error means the browser got no HTTP response. A refused connection, a missing CORS header, and an unknown host all give it, with the code ERR_NETWORK."
canonical: "https://logbrew.co/en/errors/axios-network-error"
last_updated: "2026-11-21"
---

# Fix AxiosError Network Error and find which of its 3 causes you have

`AxiosError: Network Error` means the browser got no HTTP response. A refused connection, a missing CORS header, and an unknown host all give it, with the code `ERR_NETWORK`.

Tested on November 21, 2026 with axios 1.21.1, Chrome 157, Safari 27.2, and @logbrew/browser 0.1.22

By [Furkan Erday](https://github.com/furkanerday). Furkan Erday is the founder of LogBrew. He builds LogBrew with Claude Code and Codex every day.

Canonical: https://logbrew.co/en/errors/axios-network-error

## What names the cause of an `AxiosError`

| What went wrong | `error.message` | Console |
| --- | --- | --- |
| Nothing listens on the port | `Network Error` | `ERR_CONNECTION_REFUSED` |
| No `Access-Control-Allow-Origin` header | `Network Error` | CORS policy |
| The host has no DNS record | `Network Error` | `ERR_NAME_NOT_RESOLVED` |
| No answer before the timeout | `timeout of 1000ms exceeded` | No line |
| The server answered 500 | `Request failed with status code 500` | `500` |

5 requests from axios 1.21.1 in Chrome 157.

## Find which cause you have

### Open the browser console

Axios rejects with `Network Error` and the code `ERR_NETWORK` for all 3 causes, and `error.response` is `undefined`. The stack points into Axios, not at the cause. The console line beside it names the real cause.

Output

```text
Uncaught (in promise) AxiosError: Network Error
    at XMLHttpRequest.handleError (http://127.0.0.1:28180/axios-lab.js:2491:19)
    at Axios.request (http://127.0.0.1:28180/axios-lab.js:3547:43)
```

### Nothing listens on that host and port

The console says `net::ERR_CONNECTION_REFUSED`. The API is not running, or the port in the URL is wrong. Start the API, then check the port.

Output

```text
Failed to load resource: net::ERR_CONNECTION_REFUSED
```

### The API answered without a CORS header

The console says `blocked by CORS policy`. The server answered, but the browser did not let the page read the answer. Axios got no response and gave the same `Network Error`.

Output

```text
Access to XMLHttpRequest at 'http://127.0.0.1:28181/api/taps' from origin 'http://127.0.0.1:28180' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
```

### The host name does not resolve

The console says `net::ERR_NAME_NOT_RESOLVED`. DNS has no record for the host. Check the base URL for a typo, and the environment variable that holds it on this deploy.

Output

```text
Failed to load resource: net::ERR_NAME_NOT_RESOLVED
```

### With the fetch adapter, read the cause

With `adapter: "fetch"`, Axios gives the same `Network Error` and keeps the browser's error in `error.cause`. That was `TypeError: Failed to fetch` in Chrome 157 and `TypeError: Load failed` in Safari 27.2.

## Fix it in your code

### Send the CORS header from the API

Answer with `Access-Control-Allow-Origin` set to your page's origin. In our test the same endpoint with that header answered 200, and Axios resolved.

```bash
Access-Control-Allow-Origin: https://app.example.com
```

### Log the code, the status, and the URL

Read `error.code` and `error.response` before you throw the error again. A timeout gives `ECONNABORTED`, and a 500 gives `ERR_BAD_RESPONSE` with the status. Only a network failure gives `ERR_NETWORK` with no response.

```bash
async function getTaps(url) {
  try {
    return await axios.get(url, { timeout: 1000 });
  } catch (error) {
    if (!axios.isAxiosError(error)) throw error;
    console.error(error.code, error.response?.status ?? "no response", error.config?.url);
    throw error;
  }
}
```

Output

```text
ERR_NETWORK no response http://127.0.0.1:28182/api/taps
ECONNABORTED no response http://127.0.0.1:28181/api/slow
ERR_BAD_RESPONSE 500 http://127.0.0.1:28181/api/fail
```

### Send the same request from Node.js

Node.js does not apply CORS and names the network error. The closed port gave `ECONNREFUSED`, and the unknown host gave `ENOTFOUND`. The endpoint with no CORS header answered 200, so if the request works in Node.js, look at CORS first.

```bash
import axios from "axios";

for (const url of ["http://127.0.0.1:28182/api/taps", "http://127.0.0.1:28181/api/taps", "http://keg.invalid/api/taps"]) {
  try {
    const response = await axios.get(url);
    console.log(response.status, url);
  } catch (error) {
    console.log(error.code, error.message);
  }
}
```

Output

```text
ECONNREFUSED connect ECONNREFUSED 127.0.0.1:28182
200 http://127.0.0.1:28181/api/taps
ENOTFOUND getaddrinfo ENOTFOUND keg.invalid
```

## What we saw when we tested it

We served a page at `http://127.0.0.1:28180` with axios 1.21.1 and opened it in Chrome 157 and Safari 27.2. An API at `http://127.0.0.1:28181` answered 3 paths, and we sent 5 requests with a timeout of 1,000 ms.

Both browsers gave the same `message` and `code` for each request. The 3 network failures also had `request.status` 0 and no `response`, so nothing in the error tells them apart.

|  | `error.message` | `error.code` |
| --- | --- | --- |
| Nothing listens on the port | `Network Error` | `ERR_NETWORK` |
| No CORS header | `Network Error` | `ERR_NETWORK` |
| The host has no DNS record | `Network Error` | `ERR_NETWORK` |
| No answer before the timeout | `timeout of 1000ms exceeded` | `ECONNABORTED` |
| The server answered 500 | `Request failed with status code 500` | `ERR_BAD_RESPONSE` |

## Why Axios cannot tell the causes apart

In the browser, Axios sends the request with `XMLHttpRequest`. MDN says that its `error` event fires when the request meets an error, and that JavaScript cannot read why a CORS request failed. Axios rejects with `Network Error` when that event fires.

The Axios docs say the same. `ERR_NETWORK` covers network problems and CORS, and the browser does not give the reason to the page, so look in the browser console.

axios/axios#383 asked in July 2016 for a code or a status for `Network Error`. Today `ERR_NETWORK` is that code, and it covers all 3 causes.

1. A refused connection, a CORS block, or an unknown host
2. The `error` event of `XMLHttpRequest`, with status 0
3. `AxiosError: Network Error`

- [axios/axios#383](https://github.com/axios/axios/issues/383) Set a code/status for "Network Error". Closed, 69 comments.

## What LogBrew records

Each rejection reached the SDK as an unhandled rejection. LogBrew put all 5 into 1 issue, `Unhandled promise rejection: AxiosError`, with the grouping key `browser.unhandledrejection:AxiosError:/axios-lab.js`. The message was `redacted`, so the issue does not say which request failed.

We also turned on `installLogBrewBrowserXhrInstrumentation()`, which you install yourself. It added 1 `browser.xhr` span for each request, with the method and the path. The 3 network failures had `statusCode` 0 and `errorType` `error`, the timeout had `timeout`, and the 500 had its status.

The issue also kept breadcrumbs of the requests before the error, with the method, host, port, and path. A wrong host or port in a breadcrumb points to the cause, even with no span.

|  | `statusCode` | `errorType` |
| --- | --- | --- |
| Nothing listens on the port | `0` | `error` |
| No CORS header | `0` | `error` |
| The host has no DNS record | `0` | `error` |
| No answer before the timeout | `0` | `timeout` |
| The server answered 500 | `500` | No |

## Questions people ask

### What does AxiosError Network Error mean?

Axios got no HTTP response for the request. In our test a refused connection, a missing CORS header, and an unknown host all gave this message, with the code `ERR_NETWORK`.

### Is AxiosError Network Error a CORS error?

Sometimes. A missing `Access-Control-Allow-Origin` header gives it, but so do a server that is down and a wrong host. The browser console names the cause.

### Why does the request work in Node.js but not in the browser?

Node.js does not apply CORS. In our test the endpoint with no CORS header answered 200 in Node.js and failed with `Network Error` in both browsers.

### How do I get the status code from an AxiosError?

Read `error.response?.status`. A `Network Error` has no response, so it has no status. A 500 gives `ERR_BAD_RESPONSE`, and `error.response.status` is 500.

### What is ERR_NETWORK in Axios?

`ERR_NETWORK` is the `code` of every `Network Error`. A timeout has a different code, `ECONNABORTED`, and the message `timeout of 1000ms exceeded` for a timeout of 1,000 ms.

## Find the request behind each Network Error

The LogBrew browser SDK keeps each request as a breadcrumb with its host and path, and records each `XMLHttpRequest` as a span when you turn that on. Start on the generous free tier, no card needed.

[Start Free](https://logbrew.co/en)

## Sources

- [axios docs, Error handling](https://axios.rest/pages/advanced/error-handling)
- [MDN, XMLHttpRequestEventTarget: error event](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/error_event)
- [MDN, CORS errors](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS/Errors)
- [axios/axios#383](https://github.com/axios/axios/issues/383)

## More error fixes

- [Fix the script error that hides its message, file, and line](https://logbrew.co/en/errors/script-error)
- [Fix the Failed to fetch error and tell its 3 causes apart](https://logbrew.co/en/errors/failed-to-fetch)
- [Fix java.lang.NullPointerException in Kotlin and Android from its message](https://logbrew.co/en/errors/nullpointerexception)
- [Fix Minified React error #418 and #185 from the full message and your source line](https://logbrew.co/en/errors/minified-react-error)
- [Fix SyntaxError Cannot use import statement outside a module in the browser and in Node.js](https://logbrew.co/en/errors/cannot-use-import-statement-outside-a-module)
- [Fix the HTTP 499 error and find out who stopped waiting](https://logbrew.co/en/errors/http-499)
- [JavaScript errors and JVM exceptions we reproduced, and how to fix each one](https://logbrew.co/en/errors)
