FG
🔌 APIs & SDKs

Returning "Network Error" on unauthorized error (401)

Freshover 1 year ago
Mar 14, 20260 views
Confidence Score86%
86%

Problem

Describe the issue Axios request below is returning "Network Error", on API's unauthorized return. The API is in Asp Net Core with Identity. Therefore, it is recognized that my API actually returns a 401, but my request callback is not allowing me to get this return code, so that I can handle this exception directly. I understand that, of course, my axios request tried to connect to the server, however, the identity by default doesn't even establish this connection in cases of unauthorized, it just returns the code 401, so I imagine that then axios returns this condition that there really was a "Network Error", since that's exactly what happened. I would like an idea of ​​how we can solve this. This is the code for the request in question [code block] Environment - Axios Version [0.27.2] - Adapter [e.g. XHR/HTTP] - Browser [e.g. Chrome, Safari] - Browser Version [e.g. 22] - Node.js Version [16.16.0] - OS: [Win 10] - Additional Library Versions [React 18.1.0, Next 12.1.6]

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Moderate Confidence Fix
84% confidence100% success rate1 verificationLast verified Mar 14, 2026

Solution: Returning "Network Error" on unauthorized error (401)

Low Risk

> Describe the issue > Axios request below is returning "Network Error", on API's unauthorized return. > > The API is in Asp Net Core with Identity. Therefore, it is recognized that my API actually returns a 401, but my request callback is not allowing me to get this return code, so that I can handle this exception directly. > > I understand that, of course, my axios request tried to connect to

84

Trust Score

1 verification

100% success
  1. 1

    > Describe the issue

    > Axios request below is returning "Network Error", on API's unauthorized return. > > The API is in Asp Net Core with Identity. Therefore, it is recognized that my API actually returns a 401, but my request callback is not allowing me to get this return code, so that I can handle this exception directly. > > I understand that, of course, my axios request tried to connect to the server, however, the identity by default doesn't even establish this connection in cases of unauthorized, it just returns the code 401, so I imagine that then axios returns this condition that there really was a "Netw

Validation

Resolved in axios/axios GitHub issue #4921. Community reactions: 0 upvotes.

Verification Summary

Worked: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

axioshttpapi