2

I'm Using dotnet run to start a ASP.Net core WebApi Project in my solution in VS Code after executing the command , I received below exception:

Unhandled exception. System.Net.Sockets.SocketException (10049): The requested address is not valid in its context. at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName) at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.Bind(EndPoint localEP) at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportOptions.CreateDefaultBoundListenSocket(EndPoint endpoint) at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketConnectionListener.Bind() at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportFactory.BindAsync(EndPoint endpoint, CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure.TransportManager.BindAsync(EndPoint endPoint, ConnectionDelegate connectionDelegate, EndpointConfig endpointConfig, CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.<>c__DisplayClass30_0`1.<<StartAsync>g__OnBind|0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindEndpointAsync(ListenOptions endpoint, AddressBindContext context, CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.ListenOptions.BindAsync(AddressBindContext context, CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context, CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IEnumerable`1 listenOptions, AddressBindContext context, CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken) at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken) at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken) at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token) at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token) at NGDIR.WebApi.Program.Main(String[] args) in C:\Users\FarshadFahimi\Documents\Projects\NGDIR_MSD_BACK\src\WebApi\Program.cs:line 36 at NGDIR.WebApi.Program.<Main>(String[] args) 

How can I fix this ???

2
  • Where's the exception? I see the stack trace but not the exception Commented Aug 14, 2022 at 15:32
  • @davidfowl sorry , it didn't paste completely The exception is : Unhandled exception. System.Net.Sockets.SocketException (10049): The requested address is not valid in its context. Commented Aug 15, 2022 at 4:23

1 Answer 1

1

Change the lunch port may be helpful. You can do it by the command: dotnet run --launch-profile xxx

Sign up to request clarification or add additional context in comments.

2 Comments

It worked but how should not use it in every time I wanna run my development environment??? There is a place to config this launch profile that any time I want to run , I use ** dotnet run ** only ??
Using dotnet run is not the only way, I see you are using the VSCode, so environment variables can be set in the file: .vscode/launch.json, adding the "env":{"ASPNETCORE_URLS": "localhost:xxxx"}. If you want more information about it, this Document can help you. If my answer is helpful, please give me a mark. Thank you!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.