SQL Server Express - Connect from remote machine - sql

I have two Win 7 64 bit machines.
On the first one I have installed SQL Server 2008 R2 Express and have no trouble connecting via Management Studio with Windows Auth and also via SQL Auth with a user I set up on the database.
On the second machine I am trying to connect to the database on machine 1 using Management Studio. I'm trying SQL Auth. I therefore obviously also can't connect to it via connection string in my .NET Code
I can ping the first machine from the second.
Things I have tried include the following:
On the machine the database is installed make sure the firewall is allowing connection on Port 1433
Made sure SQL Server service is running
Made sure SQL Server Browser service is running
Created an exception for sqlbrowser.exe in the firewall
Enabled TCP/IP Protocol through SQL Configuration manager
Allowed Remote connections in SQL Server Management Studio
The error I get is:
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
This is the connection string I use in code
Data Source=xxx.xxx.xxx.xxx\sqlexpress;Initial Catalog=dbName;User Id=myUser;Password=myPassword;

This can be caused by a number of reasons but I'm glad my suggestion about checking firewall ports (rather than just allowing a one-way exception for SQL Browser) led you to the answer: the firewall wasn't allowing the correct port # through.

If i remember correctly SQL Server disables remote connections by default.
Please check whether remote connections are enabled and enable them if not:
RMB on Server in Management Studio Object Explorer -> Properties -> Connections -> Allow remote connections...

Related

SQL Server Management Studio: issues with remote connections

I need to use Microsoft SQL Server Management Studio (SSMS) to connect to a remote server for my work. I have never used SSMS before and I did not install it myself as I do not have admin rights on my work computer.
I have been given a Server Name and told to choose 'Database Engine' as Server Type and 'Windows authentication' in the 'Connect to Server' window. I have asked for firewall authorisation and I have been added among the users authorised to use the remote server.
However I have not been able so far to connect because every time I open SSMS and use the 'Connect to Server' interface I always get the same 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 - The remote computer refused the network connection.) (Microsoft SQL Server, Error: 1225). --> The remote computer refused the network connection"
I double checked multiple times that the server name is correct and that I have firewall authorisation and that I am an authorised user for the remote server.
It makes me think that my version of SSMS is not enabled for remote access. I checked possible solutions all over Google but with no success. One suggestion is to right-click on the server name and in the Server Properties allow the remote connection. However i do not have any server instance in the Object Explorer window so nothing on which I could right-click on.
Does anyone have any suggestions?
Thank you in advance

Unable to connect my RDS SQL Server DB. Microsoft SQL Server, Error: 10060

I am getting below error while trying to connect my instance.
An error has occurred while establishing a connection to the server. When connecting to SQL Server, this failure may be caused by the fact that under the default settings SQL Server does not 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)`
I am using Microsoft SQL Server 2008 R2.
Thanks in advance.
To configure SQL Server 2005 to allow remote connections, you must complete these steps:
Enable remote connections on the instance of SQL Server that you
want to connect to from a remote computer.
List item Turn on the SQL Server Browser service.
Configure the firewall to allow network traffic that is related to SQL Server and to the SQL Server Browser service.
You have to enable remote connections for each instance of SQL Server 2005 that you want to connect to from a remote computer. To do this, follow these steps:
Click Start, point to Programs, point to Microsoft SQL Server 2005, point to Configuration Tools, and then click SQL Server Surface Area Configuration.
On the SQL Server 2005 Surface Area Configuration page, click Surface Area Configuration for Services and Connections.
On the Surface Area Configuration for Services and Connections page, expand Database Engine, click Remote Connections, click Local and remote connections, click the appropriate protocol to enable for your environment, and then click Apply.
Note Click OK when you receive the following message:
Changes to Connection Settings will not take effect until you restart the Database Engine service.
On the Surface Area Configuration for Services and Connections page, expand Database Engine, click Service, click Stop, wait until the MSSQLSERVER service stops, and then click Start to restart the MSSQLSERVER service.
Perhaps..
The server is powered off
Sqlserver is not running
Sqlserver is running on a different port to the default
Sqlserver is not configured to accept tcp connections (see tripuri's answer)
An interim firewall, or windows firewall is blocking the connection
There is an interim network failure between your machine and the server
You're running it locally and your recent version of windows is prohibiting loopback connections
The other answers seem to ignore the fact that this is on RDS. A couple of items to check.
Is the security group opened to allow traffic to the RDS instance?
Where is the client that you're trying to connect from?
Have you ever been able to connect to it?
Please provide details of your network and VPC configuration.
I suspect the issue is in the security group and/or issues with the VPC configuration.

Access MS SQL server remotely

I've been busy going through many of the question asked under the same topic but none of them had solved my problem.
I have MS SQL 2012 standard (trial) is installed on my local PC. Also I have a MS SQL std. server 2005 is installed on a web server (Windows Server 2003) in different domain. Normally I can RDP the web server using the static IP address given by the Infrastructure provider.
Now I wanted to access my MS SQL server installed on the web server using the MS SQL management studio installed on my local PC. but I'm receiving the following error when I try to connect. I tried with the same IP which I used to log in to the server using RDP as the server name.
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) (.Net SqlClient Data Provider)
I followed almost everything in this KB. But the windows firewall is disabled on the web server. while I'm waiting for Infrastructure provider to confirm there is no other network level firewall denies access for port:1433, I would like to know are there anything else that I'm missing here?
Problem has been resolved after forwarding the port TCP: 1433 on the router firewall.

Cannot connect to SQL server - client side issue

I might be the million'th person posting about this, but others' solutions haven't helped me. I have a database on Microsoft SQL Azure. I an trying to connect to it using the Visual Studio 2010's "Connect to Database" Tool.
From my Windows 7 machine, I can connect to it very easily. But from my Windows Server 2008R2 machine i am getting the classic 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)
All the posts around the web seem to be focussing on the problems on the server side, no one cares if the client goes rogue. :(
Thanks for the replies.
I have seen similar problems with VS2010 DB Tool and Windows Server so I would not suggest try using SSMS 2008 R2 (must be R2). Once you have download SSMS 2008 R2 and configured properly to work on Windows Server it sure will work. In most of the case you really need to open SSMS settings to get it workon on Windows Server.
Next a few points to check:
Verify that the telnet is working from your Windows Server Machine:
c:>telnet _your_sqlazure_database_name.database.windows.net 1433
Disable your real time security and the try again
Finally following the link to keep applying settings in your Windows Server and SSMS which are applicable and I am sure it will work:
http://www.mssqltips.com/sqlservertip/2340/resolving-could-not-open-a-connection-to-sql-server-errors/
One issue is that you need to connect via tcp, not named pipes (per your error message).
Are both servers behind the same firewall (e.g. the same external IP address)? The SQL Azure firewall needs to be configured to allow access from remote IP addresses.

Unable to Connect to SQL Server 2005 Db From Vista x64 Windows Service

I'm trying to connect to a remote SQL Server 2005 db from a .NET Windows service running in Vista Home Premium x64. I can access the remote db from a console app with no problem. I can connect to a local db from the Windows service with no problem. I was able to connect from a service from XP with no problem. There's no firewall or anti-virus running. How do I configure this service to be able to connect to the remote db?
I've tried to connect by running the Windows service as a local admin account, LocalSystem, LocalService, and NetworkService.
The connection string:
Data source=SERVER_NAME;Initial Catalog=DB_NAME;Integrated Security=True;
The 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)
MORE INFO:
I have also tried to connect using SQL Server authentication with no success:
Data Source=SERVER_NAME;User ID=USER_ID;Password=PWD;Initial Catalog=DB_NAME
This connection string works from the console app too.
MORE INFO:
I ran Process Monitor for the Windows Service and the console app. The Windows service showed \SERVER_NAME\pipe\sql\query was ACCESS DENIED but the console app showed SUCCESS when reading/writing files to \SERVER_NAME\pipe\sql\query.
Good Lord! Why all the gibberish and complex responses on this site. Create a User Account
Either local or Domain and set the service to use that account. Then go into your SQL Server and Add you new account to the Database and set permissions. Voila!
Oh yeah, dont plague yourself with SQL Authentication. Integrated Security is much easier to maintain and without a password in your web.config your much safer.
1) open a command prompt. Type "ping SERVER_NAME". Does it respond? You may have a DNS or connectivity issue if this doesn't work.
2) "telnet SERVER_NAME 1443". Do you see anything or does it refuse your connection? This will definitively tell you whether or not someone is listening on the other end.
3) Go into SQL Server Management Studio. Right click Properties of your server. Select "Connections" from the left side. Is "Allow Remote Connections" checked?
4) Since you're running using network service/system, you will need to make sure you have a login configured on your server for the machine account DOMAIN\CLIENTSYSTEMNAME$. Note the $ sign. This is your machine account, and this will be the user that SQL Server will see.