I just installed SQL Server Express 2012 on my home server. I'm trying to connect to it from Visual Studio 2012 from my desktop PC, and repeatedly getting the well-known 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
What I've done to try to fix this:
- Run SQL Server Configuration Manager on the server and enable SQL Server Browser
- Add a Windows Firewall exception on the server for TCP, ports 1433 and 1434 on the local subnet.
- Verify that I have a login on the SQL Server instance for the user I'm logged in as on the desktop.
- Verify that I'm using Windows Authentication on the SQL Server instance.
- Repeatedly restart SQL Server and the whole dang server.
- Pull all my hair out.
How can I get SQL Server 2012 Express to allow remote connections!?
On my installation of SQL Server 2012 Developer Edition, installed with default settings, I just had to load the SQL Server Configuration Manager -> SQL Server Network Configuration -> Protocols for MSSQLSERVER and change TCP/IP from Disabled to Enabled.
Well, glad I asked. The solution I finally discovered was here:
How do I configure SQL Server Express to allow remote tcp/ip connections on port 1433?
So far, so good, and entirely expected. But then:
(Also, if you follow these steps, it's not necessary to enable SQL Server Browser, and you only need to allow port 1433, not 1434.)
These extra five steps are something I can't remember ever having had to do in a previous version of SQL Server, Express or otherwise. They appear to have been necessary because I'm using a named instance (myservername\SQLEXPRESS) on the server instead of a default instance. See here:
Configure a Server to Listen on a Specific TCP Port (SQL Server Configuration Manager)
This article helped me...
How to enable remote connections in SQL Server
Everything in SQL Server was configured, my issue was the firewall was blocking port 1433
I had to add a firewall inbound port rule to open UDP port 1434. This is the one Sql Server Browser listens on.
One more thing to check is that you have spelled the named instance correctly!
This article is very helpful in troubleshooting connection problems: How to Troubleshoot Connecting to the SQL Server Database Engine
I had this problem recently. 2015 Aug
Solved by opening SQL Server Configuration Manager
Can connect to with SQL Server Manager to machine: [hostaddress], 1433
Example: