Solved

Unable to connect to SQL Server

Posted on 2010-09-23
7
1,275 Views
Last Modified: 2012-05-10
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
Comment
Question by:irb56
  • 4
  • 3
7 Comments
 
LVL 16

Expert Comment

by:carsRST
ID: 33748076
you need to open port 1433 on your firewall.  that's the default port for SQL Server.
0
 
LVL 16

Accepted Solution

by:
carsRST earned 500 total points
ID: 33748092
Here are some basic instructions for opening a port for windows firewall

http://support.microsoft.com/kb/308127
0
 

Author Comment

by:irb56
ID: 33748716
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 16

Expert Comment

by:carsRST
ID: 33750388
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
 

Author Comment

by:irb56
ID: 33761247
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
 

Author Comment

by:irb56
ID: 33763528
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
 

Author Closing Comment

by:irb56
ID: 33768116
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

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup". After a while, you have entered a loop for Auto repair which does not fix anything and you will be in a  panic as all your work w…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This Micro Tutorial will give you a basic overview of Windows Live Photo Gallery and show you various editing filters and touches to photos you can apply. This will be demonstrated using Windows Live Photo Gallery on Windows 7 operating system.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now