Why ASP.Net Core 7.0 Web API showing as Connection refused?

Posted by Vishalneeraj-24503 under ASP.NET Core on 2/16/2023 | Points: 10 | Views : 2356 | Status : [Member] [MVP] | Replies : 0
I am new to asp.net core 7.0.

I am working on the Web Api. However I created one controller with [ApiController] decoration.

In the launchSettings.json file it shows port number as 14023 as shown below :-

"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:14023",
"sslPort": 44381

Means that my Web API will be pointing to http://localhost:14023

However when I run the application and navigate to http://localhost:14023 it shows below error :

This site can’t be reached

localhost refused to connect.


And when I hit the same API URL through Postman then below error coming :-

Error: connect ECONNREFUSED

Initially I thought that it could be related to CORS so I added below code in Program.cs file :-


app.UseCors(options =>

Can anyone help me on this?

I am stuck. Even I googled but did not find any suitable answer.


(No response found.)

Login to post response