Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An attempt was made to access a socket in a way forbidden by its access permissions

I have a website on HostGator and a dedicated server of my own running SQL Server 2008R2. The connection string I use is X.X.X.X,1433 which points to the IP address of my dedicated server. I have made the firewall settings on my server so that I can use SSMS & log into SQL Server from my home PC.

Having done that, I was under the impression that connecting to SQL from my hostGator hosted-site would work just fine. I receive the following error:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - An attempt was made to access a socket in a way forbidden by its access permissions.)

I have looked up this error and found many explanations, but not one dealing with my circumstances. My server is running Windows 2008 w/IIS 7.5. I was assured by HostGator tech support that there would be no problems from their end.]]

My firewall allows TCP port 1433, & the UDP port 1434 for the SQL Server Browser service.

Since I have a dedicated server, I have no one to ask this question to from my hosting company.

like image 372
Jerry Avatar asked Mar 25 '13 16:03

Jerry


People also ask

Could not bind server socket An attempt was made to access a socket in a way forbidden by its access permissions?

The application is trying to open a port that is already used – One of the most common reasons why this error occurs is if you try to use an application that is configured to open a port that is already opened and actively used by a different service or application.


1 Answers

I had a similar issue with Docker for Windows and Hyper-V having reserved ports for its own use- in my case, it was port 3001 that couldn't be accessed.

  • The port wasn't be used by another process- running netstat -ano | findstr 3001 in an Administrator Powershell prompt showed nothing.
  • However, netsh interface ipv4 show excludedportrange protocol=tcp showed that the port was in one of the exclusion ranges.

I was able to follow the solution described in Docker for Windows issue #3171 (Unable to bind ports: Docker-for-Windows & Hyper-V excluding but not using important port ranges):

  1. Disable Hyper-V:

    dism.exe /Online /Disable-Feature:Microsoft-Hyper-V 
  2. After the required restarts, reserve the port you want so Hyper-V doesn't reserve it back:

    netsh int ipv4 add excludedportrange protocol=tcp startport=3001 numberofports=1 
  3. Reenable Hyper-V:

    dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All 

After this, I was able to start my docker container.

like image 170
tessafyi Avatar answered Oct 02 '22 12:10

tessafyi