I restarted this service :Host Network Service
on windowsServices
program. And it worked.
You can run these commands in the windows terminal instead, as @admin mentioned in comment section:
net stop hns
net start hns
Most likely the socket is held by some process. Usenetstat -o
to find which one.
Reload Visual Studio with Administrator privileges. Windows Sockets (WinSock) will not allow you to create a SocketType.RAW Socket without Local Admin. And remember that your Solution will need elevated privileges to run as expected!
Well I don't even understand the culprit of this problem. But in my case the problem is totally different. I've tried runningnetstat -o
ornetstat -ab
, both show that there is not any app currently listening on port 62434 which is the one my app tries to listen on. So it's really confusing to me.
I just tried thinking of what I had made so that it stopped working (it did work before). Well then I thought of the Internet sharing I made on my Ethernet adapter with a private virtual LAN (using Hyper-v in Windows 10). I just needed to turn off the sharing and it worked just fine again.
Hope this helps someone else having the same issue. And of course if someone could explain this, please add more detail in your own answer or maybe as some comment to my answer.
IIS was the main offender for me. My IIS was running and it restrains any new socket connections from opening.
The problem was resolved for me by stopping IIS by running the command "iisreset -stop
"
In addition to this, if you use docker, Docker might be the cause of this problem. If so, you have to restart Host Network Service by executing the below command. You may need elevated access to executing this command
"net stop hns && net start hns
"
I've had this problem when trying to start a dotnet Core project using dotnet run when it tried to bind to the port.
The problem was caused by having a Visual Studio 2017 instance running with the project open - I'd previously started the project via VS for debugging and it appears that it was holding on to the port, even though debugging had finished and the application appeared closed.
Closing the Visual Studio instance and running "dotnet run" again solved the problem.
I had a similar problem but I fixed it by doing some changes in the firewall setting.
You can follow the below steps
Go to "Start" --> "Control Panel"
Inside Windows Firewall, click on "Allow a program or feature through Windows Firewall"
Now inside of Allow Programs, Click on the "Change Settings" button. Once you click on the Change Settings button, the "Allow another program..." button gets enabled.
When you click on the "Allow another program..." button, a new dialog box will appear. Choose the programs or applications for which you are getting the socket exception and click on the "Add" button.
Click OK, and restart your machine.
Try to run your application (which has an exception) with administrative rights.
I hope this helps.
When a process uses a port, it cannot be used by another process.netstat -o
shows the ports being used by a process.
Alternatively, ports can also be excluded from usage. In that case, no process can use them. You can see the list vianetsh interface ipv4 show excludedportrange protocol=tcp
This is the error that is returned when the Windows Firewall blocks the port (out-going). We have a strict web server so the outgoing ports are blocked by default. All I had to do was to create a rule to allow the TCP port number in wf.msc.
I ran into this in a Web App on Azure when attempting to connect to Blob Storage. The problem turned out to be that I had missed deploying a connection string for the blob storage so it was still pointing at the storage emulator. There must be some retry logic built into the client because I saw about 3 attempts. The/devstorageaccount1
here is a dead giveaway.
Fixed by properly setting the connection string in Azure.
I'm developing a UWP application which connects to an MQTT broker in the LAN. I got a similar error.
MQTTnet.Exceptions.MqttCommunicationException: 'An attempt was made to access a socket in a way forbidden by its access permissions [::ffff:xxx.xxx.xxx.xxx]:1883'
ExtendedSocketException: An attempt was made to access a socket in a way forbidden by its access permissions [::ffff:xxx.xxx.xxx.xxx]:1883
Turned out that I forgot to give the app the correct capabilities ...
Runningiisreset
in a command window fixed it for me.
I've just had a similar problem, from a Xamarin Forms application, which was making an outbound call to Azure via HttpClient.
In my case the root cause of the problem turned out to be my security suite, BitDefender, blocking outbound access for my application, because it thought it was a threat.
I've added an exception to the firewall for this application and it has solved the problem.
I solved simply stopping the installed version of the service that was running in the machine using the same port.
Alternatively, run the debug instance with a different port.
I had the same error happening when I had two different ASP.net projects in two different Visual Studio instances.
Closing one of them fixed the issue.
As noted by Gonnagle, this can be caused by having an installed VPN client in the connected state. For us, disconnecting from the VPN resolved the issue.
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.