Use alternate address if default address is already in use
See original GitHub issueConsider this feature request coming from an early-stage dev so i don’t have much knowledge in configuring ports manually 😅
Is your feature request related to a problem? Please describe. I was wondering why the server didn’t spin up, then realised that i have been running one on the same port address 💡
Describe the solution you’d like Ability to detect if an address is already in use and if then automatically fallback to a different address to spin up the dev server.
Describe alternatives you’ve considered Quit current server, run the other one, quit that one, run the first one.
Additional context
This is the message that is being logged when i run dotnet run --project ../Perla -- serve
Checking esbuild is present...
esbuild is present.
Starting Dev Server
Unhandled exception. System.AggregateException: One or more errors occurred. (Failed to bind to address http://127.0.0.1:7331: address already in use.)
---> System.IO.IOException: Failed to bind to address http://127.0.0.1:7331: address already in use.
---> Microsoft.AspNetCore.Connections.AddressInUseException: Address already in use
---> System.Net.Sockets.SocketException (48): Address already in use
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()
--- End of inner exception stack trace ---
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)
--- End of inner exception stack trace ---
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindEndpointAsync(ListenOptions endpoint, AddressBindContext context, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.LocalhostListenOptions.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 Perla.Server.startServer@485.Invoke(Unit unitVar) in /Volumes/Work/oss/perla-forked/Perla/src/Perla/Server.fs:line 485
at Ply.TplPrimitives.ContinuationStateMachine`1.System-Runtime-CompilerServices-IAsyncStateMachine-MoveNext()
--- End of inner exception stack trace ---
at Microsoft.FSharp.Control.AsyncPrimitives.Start@1077-1.Invoke(ExceptionDispatchInfo edi)
at Perla.Server.Pipe #1 input at line 500@502-3.Invoke(AsyncActivation`1 ctxt) in /Volumes/Work/oss/perla-forked/Perla/src/Perla/Server.fs:line 502
at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 104
at <StartupCode$FSharp-Core>.$Async.clo@181-16.Invoke(Object o) in D:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 183
at System.Threading.QueueUserWorkItemCallbackDefaultContext.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
at System.Threading.Thread.StartCallback()
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Customer's default address is always getting replaced with ...
I just wanted to confirm this is expected behaviour. On creation of a new order if the shipping address is different than the...
Read more >DHCP address already in use... um actually it isn't
I had one of our servers setup using an IP address, but over my time of being mostly away from the office, at...
Read more >Add and Manage Addresses - Amazon Customer Service
You can add, edit, and delete addresses for future orders. You can also select a default address to make it easier to place...
Read more >How To Change Your Delivery Address On Amazon - YouTube
Remove, and add an address to your Amazon account. ... Use Fiverr and get some free credit here: https://bit.ly/FiverrDusty Connect With Me ...
Read more >Add and Manage Addresses - Amazon Customer Service
Add and Manage Addresses ... You can add, edit, and delete addresses for future orders. You can also select a default address to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is out in v0.16.0
Great news!
I would like to check this for myself but i fear i wouldn’t have the time until the weekend. I would recommend you to go for it.