Post written June 10, 2010 and pertains to:
- SQL Server 2008 R2 Express on both my server and local machines: SQLX_SRV,SQLX_LOC
- SQL Server 2008 R2 Management Studio on both my server and local machines:
MS_SRV, MS_LOC
- Windows Server 2008 R2 Enterprise installed on a Hyper-V VPS: WS
- SQL Server Configuration Manager on both my server and local machines:
CMGR_SRV, CMGR_LOC
- Server Manager: SMGR
- I am connecting to my hosting server via Remote Desktop Connection: RDC
I installed SQLX_SRV and MS_SRV on my hosting server and SQLX_LOC and MS_LOC on my local development machine. I am able to use MS_LOC to connect to SQLX_LOC and to use MS_SRV to connect to SQLX_SRV. However I am not able to use MS_LOC to connect
with SQLX_SRV. Here's what I have done so far:
- SMGR -> Configuration -> Windows Firewall to turn off the Windows Firewall for Domain, Private and Public profiles. Obviously I'll change this later, but until I can connect I want to remove as many variables as possible.
- CMGR_SRV -> SQL Server Services to confirm that both SQL Server (SQLEXPRESS) and SQL Server Browser services were running.
- CMGR_SRV -> SQL Server Network Configuration -> Protocols for SQLEXPRESS to ENABLE the Shared Memory, Named Pipes, and TCP/IP protocols and DISABLE the deprecated VIA protocol.
- CMGR_SRV -> SQL Server Network Configuration -> Protocols for SQLEXPRESS -> double click TCP/IP to open the TCP/IP properties dialogue. On the Protocol tab Enabled: Yes, Keep Alive: 30000, changed Listen All to No. I've tried it both
ways, but I've got six IP addresses on my server and I wanted to configure SQLEXPRESS to listen to only the first and primary IP. On the IP Addresses tab went to IPALL and cleared the TCP Dynamic Ports field and entered 1433 in the TCP Port field.
For my first and primary IP Address I made sure that Enabled was Yes, I cleared the TCP Dynamic Ports field, and entered 1433 in the TCP Port field. For all other IP Addresses Enabled was set to No and I cleared both the TCP Dynamic Ports and TCP Port
fields.
- CMGR_SRV -> SQL Server Services -> SQL Server (SQLEXPRESS) right click and Restart. This of course stopped and restarted my instance of SQLX_SRV enabling the TCP/IP configuration in the previous step to take effect.
On my server, SQLX_SRV is the only instance of SQL Server running and so it's easy to hard wire it to the default port 1433.
The instance name for both SQLX_SRV and SQLX_LOC is the default "SQLEXPRESS". My server machine name is "SERVER1" on the EnglishBrains.com domain. So the proper local name (local within the context of my remote server as connected via RDC) for
my instance of SQLX_SRV would be:
SERVER1\SQLEXPRESS
Note the use of a backslash NOT a forward slash.
Of course to connect remotely from my development machine, which is not on the same domain as my hosting server, I would need to specify the domain as well, so the SQL Server name becomes:
SERVER1.EnglishBrains.com\SQLEXPRESS
I must also use SQL Server Authentication. Before I can use such a remote connection, however, there are still several configuration steps required. So on my server (connected via RDC) I used MS_SRV to connect to SQLX_SRV using SERVER1\SQLEXPRESS
for the server name and Windows Authentication. Once connected I performed the following steps:
- MS_SRV -> right click the connected parent SERVER1\SQLEXPRESS instance node at the top -> Properties -> Security -> Server authentication: select "SQL Server and Windows Authentication mode". This will enable connections using either type
of authentication.
- Next, leaving the Server Properties dialogue open, Connections -> check "Allow remote connections to this server" box.
- Click OK to save these changes and close the Server Properties dialogue.
- MS_SRV -> Security -> right click Logins and select "New Login...", the Login - New dialogue opens.
- On the General page Enter a name for your new login
- Select SQL Server Authorization
- Enter and confirm a password
- Uncheck Enforce password expiration
- Select the default Database and Language
- On the ServerRoles page Public will be checked, also check SysAdmin. This is probably not a good idea and I'll uncheck this as soon as I can connect to the SQLX_SRV.
- On the User Mapping page select the databases you want your new Login to access and enter the Default Schema of "dbo".
- At the bottom of the User Mapping page you'll see the Database Roles table. Public will be selected by default. Also select db_Owner. Again this is probably not a good idea, and I'll refine this once I can connect.
- On the Status page confirm that "Grant" is checked under "Permission to connect to database engine" and "Enable" is checked under "Login".
- Click OK to save all changes and close the Login - New dialogue.
With these steps completed you should now be able to use MS_SRV to connect to SQLX_SRV using SQL Server Authentication by supplying the name and password for your new Login. I tried this and it worked fine. Next I tried to use this same login
remotely, that is I went to my local development machine and used MS_LOC to try and connect to SQLX_SRV by using
SERVER1.EnglishBrains.com\SQLEXPRESS
and opting for SQL Server Authentication and supplying the name and password of my new login.
THIS DID NOT WORK?? Instead I get the following error message:
---------------------------
Cannot connect to SERVER1.EnglishBrains.com\SQLEXPRESS.
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)
For help, click:
http://www.microsoft.com/products/ee/transform.aspx?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=-1
------------------------------
If you follow the suggested help link, you are told:
The SQL Server client cannot connect to the server. This error could be caused by one of the following reasons:
- A specified SQL Server instance name is not valid.
- The TCP, or named pipes protocols are not enabled.
- The firewall on the server has refused the connection.
- The SQL Server Browser service (sqlbrowser) is not started.
WRONG on all 4 counts! The instance name IS valid. Both TCP/IP and Named Pipes protocols are enabled. The firewall has been shut down, so it is not relevant. Finally the SQL Server Browser IS started.
The next thing I tried was to circumvent discovery by the SQL Browser service by using the following syntax to specify the IP address and port directly when specifying the SQL Server name.
tcp:68.71.134.186,1433
Using this in the Server Name field I was able to use MS_SRV to successfully connect to SQLX_SRV (using SQL Server Authentication of course) with or without the SQL Browser service running.
However when I tried to connect from MS_LOC to SQLX_SRV using this same login (WITH SQL Browser service running just for good measure) it does not work?? I get the following error message:
------------------------------
Cannot connect to tcp:68.71.134.186,1433.
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 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.) (Microsoft SQL Server, Error: 10060)
For help, click:
http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=10060&LinkId=20476
------------------------------
If you follow the help link you are told:
"The SQL Server client cannot connect to the server. This error could occur because either the firewall on the server has refused the connection or the server is not configured to accept remote connections."
However, the firewall has been shut down and the server HAS been configured to accept remote connections!
I confirmed that i could indeed Ping to 68.71.134.186 and running NetStat -a |find /i "listening" on the server shows that the server is indeed listening at 68.71.134.186 Port 1433 -- which is why I was able to connect to SQLX_SRV using MS_SRV with
tcp:68.71.134.186,1433 .
IN SUMMARY: Even though I can connect to my SQLEXPRESS instance multiple ways from the server itself, I cannot connect remotely from my development machine!
If anyone can help me figure out why I would be very, very grateful!