Unable to bind to localhost on the IPv4 loopback interface: An attempt was made to access a socket in a way forbidden by its access permission

Question: How to run a Console Application with Dependency Injection, then click on run the error "Unable to bind to localhost on the IPv4 loopback interface: An attempt was made to access a socket in a way forbidden by its access permission" is written to the Console.

Any idea how to solve it?

Answer: This error is most likely to happen when you have another application listening on the same port. Another theory is that you are trying to use the Console Application as a web application that requires a Home or Index Razor File. If you are trying to make a Console Application do an ETL like Job Scheduler then you should look into creating an API and then just call the URL endpoint. 

Let me know what your scenario is in the comments below.


Edit this Article
API Console Application with Dependency Injection ebook e-book AspNet 6 .NET 6 published
Was this page helpful?
Yes Yes! this solution to the problem was helpful. No No! this solution to the problem was not helpful.. Leave ErnesTech Feedback.Feedback
If you log in, you will be notified when someone leaves a comment.

Other users would like to know if this solution helped you.

Your Session is Ending
Login to Continue

© 2021 - ErnesTech - Privacy