© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
32 replies
James213

✅ Frontend unable to connect to webapi when starting server manually (dotnet run)

When I run my C# Webapi project through Visual Studio Code debugger (or VS) then my reactapp can make a GET request to the webapi, however if I start up the webapi via cmd
dotnet run
dotnet run
and make a GET request I get
net::ERR_CONNECTION_REFUSED
net::ERR_CONNECTION_REFUSED


This is the output from VS Code when I start the webapi through the debugger.
 *  Executing task: C:\Program Files\dotnet\dotnet.exe build C:\Users\Username\source\repos\Username\InsuranceCalculator/InsuranceCalculator.sln /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary 

MSBuild version 17.6.1+8ffc3fe3d for .NET
  Determining projects to restore...
  All projects are up-to-date for restore.
  webapi -> C:\Users\Username\source\repos\Username\InsuranceCalculator\webapi\bin\Debug\net7.0\webapi.dll
 *  Terminal will be reused by tasks, press any key to close it. 
 *  Executing task: C:\Program Files\dotnet\dotnet.exe build C:\Users\Username\source\repos\Username\InsuranceCalculator/InsuranceCalculator.sln /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary 

MSBuild version 17.6.1+8ffc3fe3d for .NET
  Determining projects to restore...
  All projects are up-to-date for restore.
  webapi -> C:\Users\Username\source\repos\Username\InsuranceCalculator\webapi\bin\Debug\net7.0\webapi.dll
 *  Terminal will be reused by tasks, press any key to close it. 


This is the output from cmd when I start the webapi through the cmd.

C:\Users\Username\source\repos\Username\InsuranceCalculator\webapi>dotnet run
Building...
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:5206
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
      Content root path: C:\Users\Username\source\repos\Username\InsuranceCalculator\webapi 
C:\Users\Username\source\repos\Username\InsuranceCalculator\webapi>dotnet run
Building...
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:5206
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
      Content root path: C:\Users\Username\source\repos\Username\InsuranceCalculator\webapi 
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Unable to run dotnet project
C#CC# / help
3y ago
Cookies help Dotnet webapi
C#CC# / help
2y ago
❔ WebAPI Cors problem when calling API from Frontend
C#CC# / help
3y ago