The “Network Error” in Axios is a common issue when a React, Angular, or other frontend application attempts to call an ASP.NET Core Web API but fails before receiving a valid HTTP response. Unlike a 4xx or 5xx status code, this error typically indicates that the request never successfully reached the .NET backend or was blocked by the browser. Understanding the root causes such as CORS misconfiguration, HTTPS issues, incorrect base URLs, SSL problems, or server downtime is essential for resolving this issue in production environments.
This article explains the most common causes of the Axios “Network Error” when calling a .NET API and provides practical solutions for each scenario.
1. Fix CORS Configuration in ASP.NET Core
The most common cause of Axios “Network Error” is CORS (Cross-Origin Resource Sharing) misconfiguration. If the frontend and backend run on different ports or domains, the browser blocks the request.
Configure CORS properly in Program.cs:
builder.Services.AddCors(options =>
{
options.AddPolicy("AllowFrontend",
policy => policy
.WithOrigins("http://localhost:3000")
.AllowAnyHeader()
.AllowAnyMethod());
});
var app = builder.Build();
app.UseCors("AllowFrontend");
If credentials (cookies or authentication headers) are required:
policy.WithOrigins("http://localhost:3000")
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
Improper CORS setup results in browser-blocked requests, which Axios reports as “Network Error.”
2. Verify API Base URL in Axios
Incorrect API URLs cause connection failures.
Incorrect:
axios.get("/api/products");
Correct:
axios.get("https://localhost:5001/api/products");
Always ensure:
Correct protocol (http vs https)
Correct port number
Backend server is running
For better maintainability, configure a base URL:
const api = axios.create({
baseURL: "https://localhost:5001/api"
});
3. Fix HTTPS and SSL Certificate Issues
If your .NET API uses HTTPS with a development certificate, the browser may block requests due to untrusted SSL certificates.
Run:
dotnet dev-certs https --trust
Restart both backend and frontend after trusting the certificate.
Mixed content errors (HTTP frontend calling HTTPS backend or vice versa) can also trigger network errors.
4. Check Backend Server Status
If the ASP.NET Core Web API is not running or crashes during startup, Axios cannot establish a connection.
Verify:
The API is running
No runtime exceptions during startup
The correct launch profile is selected
Firewall is not blocking the port
Try accessing the API endpoint directly in the browser to confirm availability.
5. Handle Large Payload or Request Timeout Issues
If uploading large files or sending large JSON payloads, the server may reject the request.
Increase request size limit in ASP.NET Core:
builder.WebHost.ConfigureKestrel(options =>
{
options.Limits.MaxRequestBodySize = 52428800; // 50 MB
});
Also configure Axios timeout:
axios.get("https://localhost:5001/api/data", {
timeout: 10000
});

Join the conversation! Your thoughts help the community grow.