• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1338
  • Last Modified:

Unable to connect to SQL Server

Hi,

I have a PC with Windows 7 Pro and SQL Server 2008 R2 installed and a laptop with Windows 7 Home and SQL Server 2008. I have added a Windows Firewall rule on the PC to allow incoming TCP connections on port 1433. Both the PC and the laptop are connected wirelessly to the same Homegroup network.

When I try to connect to the SQL Server 2008 R2 instance on the PC from SSMS on the laptop, I get the following error:

Cannot connect to MyPC\SVR1.
------------------------------
ADDITIONAL INFORMATION:

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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) (Microsoft SQL Server, Error: -1)

I have deduced that the problem is caused by the Windows Firewall on the PC because when I disable it temporarily, the connection works fine. Can someone please advise me how to configure Windows Firewall on the PC so that it allows my remote connection from the laptop without unduly compromising security on the PC?

Thanks in advance.
0
irb56
Asked:
irb56
  • 4
  • 3
1 Solution
 
carsRSTCommented:
you need to open port 1433 on your firewall.  that's the default port for SQL Server.
0
 
carsRSTCommented:
Here are some basic instructions for opening a port for windows firewall

http://support.microsoft.com/kb/308127
0
 
irb56Author Commented:
As far as I can tell, the Windows Firewall configuration has TCP port 1433 open. I found the following article which informed me that my named instance was listening on dynamic ports (http://technet.microsoft.com/en-us/library/ms177440.aspx). I used the SQL Server Configuration Manager to explicitly set to listen on port 1433. I restarted the service but still no luck connecting.

The following article, http://technet.microsoft.com/en-us/library/ms175043.aspx, told me how to configure Windows Firewall to open up SQL Server access for dynamic ports. As soon as I put this rule in the firewall, I am able to connect.

As far as I can tell, the server has TCP port 1433 open in the Windows 7 Firewall and is configured to listen on port 1433 (i.e. not use dynamic ports). Why can't I connect without this broad firewall rule that allows all remote connections to Sqlservr.exe regardless of port number?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
carsRSTCommented:
With the dynamic ports, there's no guarantee which port it will pick.  And you definitely don't want to leave all open.  By configuring the way you have, windows firewall will allow which ever port is being used at the time access out...and only that port.
0
 
irb56Author Commented:
Thanks and you're right that I don't want to leave the firewall to allow access to SQL Server via any port (i.e. dynamic ports). I want to allow access to port 1433 only. I've configured Windows Firewall to open port 1433 and I've configured SQL Server (which is a named instance, not the default instance) to use port 1433 rather than dynamic port. I must have made a silly mistake in one of these two configurations, which I'm currently blind to. If someone can provide detailed list of things to check, that will be helpful.

Many thanks.
0
 
irb56Author Commented:
I worked out the problem. My mistake was made not in the firewall configuration but in the SQL Server Configuration Manager. In the network configuration for TCP/IP, I changed the TCP Dynamic Ports to blank and the TCP port to 1433. I did this for all IP address, IP1 to IP9. My mistake was that the IPAll entry was blank for TCP port and had a value of 49747 for TCP Dynamic Ports. Also I had accidentally set TCP Dynamic Ports to 1433 with a blank TCP port on IP7 (i.e. a transposition of what I meant to do).

Once I corrected the aforementioned configuration mistakes and disabled the firewall rule that allowed any port access to SQL Server (relying instead on the more restrictive TCP port 1433 only rule), my problem was resolved and I was able to connect to the SQL Server named instance remotely across my private network.
0
 
irb56Author Commented:
My issue was actually caused by a configuration mistake in SQL Server Configuration Manager for TCP/IP rather than the Windows Firewall but thanks for your assistance as it seemed just as probable at the outset that I made a mistake in the firewall config.

See my posting on 26/09/10 for more details on how I solved the issue.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now