SQL Server 2008 R2 First-Time Connection Issues - sql-server

We've been experiencing a strange issue with SQL 2008 R2 (10.50.1600) installed as a named instance. In order for any external clients to connect, we have a certain procedure we have to follow, but should not have to. Now I did in fact open the TCP/IP and Named Pipes protocols on the SQL server and restarted it, this isn't the problem. We're on an Active Directory Domain (running from Server 2003). The problem exists no matter what OS the server or client is (XP, 2003, 2008, Vista, 7, 64bit, 32bit, etc.). The problem also persists from anything which can connect, for example, SQL Management Studio, ADO (from our applications), etc.
The problem is that before any client can connect to this server, each client machine must first connect to this server through ODBC (and we don't use ODBC). Any attempt to connect to a 10.5 SQL server before doing this results in "Server does not exist or access denied". But once we can connect in the ODBC (through Named Pipes), then everything else starts to work. The same issue occurs both when using the Computer Name and IP Address. In fact, if we want to connect with computer name \ instance name, then we have to do so first in the ODBC, and then if we want to connect via the IP address \ instance name, then we have to do the same also for that.
We've been having to do this on every single client computer. Again, once the ODBC is able to connect to this SQL server through Named Pipes, then all future attempts from that client work.
What could be causing this to occur? How to avoid it? I should not have to do this "ODBC Trick" as we've been calling it. I've never had this issue on any other version of SQL.

The issue might be related to the SQL Browser service. Each sql instance will have a different port number - try connecting from the client as IP Address,Port (e.g. 123.123.123.1,1433) - this will exclude DNS and Browser from the equation
Edit: now knowing that it is browser related, try see why clients can't access SQL Browser (usually Port 1434). Service not started? Possibly firewall blocking?
Microsoft have tied down everything security wise now by default, so any new configuration now generally requires quite a bit of detailed security planning, policy configuration, permissions etc. Welcome to the age of non-trust ;)

You could easily test your connection by creating a simple file. Follow the steps here at "How to test an SQL Server connection": http://teusje.wordpress.com/2012/02/21/how-to-test-an-sql-server-connection/

Related

SQL Server instance list in ODBC not populating

I have two computers connected to the same switch on the same network with the same subnet, and when I go to either 32 or 64-bit ODBC to create a System DSN and attempt to add a new DSN using the SQL Server Native Client 11.0, the Server list is empty on one but fully populated on the other. I have a local SQL Server on both computers.
The last two entries above are from the computer that is not working. So the SQL Server on the non-working machine has an available instance.
For the computer that is NOT showing any SQL Servers I have tried the following with no success:
Upgraded the OS from Windows 10 to Windows 11
Followed the directions from Microsoft to open ports TCP 1433 and UDP 1434
Made sure the option to hide my SQL server instance is not enabled
Reinstalled ODBC drivers
Checked permissions
Nothing is working. Even my other computer can see my SQL Server instance, but I can't. I can type the server instance manually and that works. But I am dying to figure this out! This makes no sense to me. Also, the computer that works takes almost no time to build the list. On the computer that it's not working, it sits there for a long time before coming back empty.
I thought this could be a permission issue with my account, but it works fine on my other computer using the same account. The only other thing I can think of is it might be a policy issue, but I'm not sure where to go or look for a policy that might affect it. These are both work computers on a domain and even support here can't figure it out.
Any help/direction is appreciated. Thanks!

Cannot connect to remote sql database with an error 26

I have a small application that uses a SQL-Server express 2005 database located on a remote machine. This has worked for years. I've not only been able to access it via the application, but also on the development machine. The other day I came in to the server (windows 7 machine) shut down from a power outage. Since then I have not been able to access the database and receive an error 26. I have checked the firewall and it does indeed have the exception for sqlbrowser and UDP 1434 set. I also checked Configuration Manager and SQL Server (SQLEXPRESS) and SQL Server Browser are both running. (Even did a restart on both)
Client Protocols are enabled for Shared Memory, TCP/IP and Named Pipes.
Here is where it gets strange (At least for me). Both the development machine and the machine that uses the application that works with the database were both set to Obtain IP Address. If I set these to a static address they are then able to access the database without issues. I would like to not have to set static IP's and get things running the way they have for the past couple of years. Does this shed any light on what I might need to check to see why I can no longer access this server without a static IP on the remote machines?
The server is 2007 pro along with the development machine. The remote machine that uses the application is Windows 10 pro.
I should also state that I can browse the network and access normal shares via windows network with and without the static ip from both machines.
EDIT: The exact message I get when I don't use a static ip 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. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) (Microsoft SQL Server)
I get this error even when trying to connect using Microsoft SQL Server Management Studio Express.
After many installations I learned that opening the SQL Server port in the firewall works always when using the default instance, but with named instances and SQL Browser opening the ports some times doesn't prevent the firewall for blocking connections, specially in small environments that doesn't have a proper server like the one you describe (I think that it's related to the dynamic port feature that SQL Server use by default with named instances, but I'm not sure).
When I have to use named instances instead of opening the ports I create rules for the programs themselves and it has worked fine until now. Create two rules using New rule > Programs > This program path, one for:
C:\Program Files\Microsoft SQL Server\90\Shared\sqlbrowser.exe
and other for:
C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn\sqlservr.exe (maybe this location is a bit different when using the SQLEXPRESS instance).
I usually create the rules only for private network locations, but maybe you should create the rules for all locations just to be sure (and if this works, try unchecking public locations from the rules).
For future installations note that you can configure Express editions to use the default instance MSSQLSERVER at install time (and only at install time), with that option you just open port 1433 and you are done.

SQL Server: "a connection was successfully established with server....existing connection was forcibly closed by the remote host."

Yes folks, it's this one again.
"A connection was successfully established with the server, but then
an error occurred during the login process (provider: TCP Provider,
error: 0 - An existing connection was forcibly closed by the remote
host.)"
I'm sorry... I have Google'd this, I have read the other StackOverflow articles on this problem, and I have tried all kinds of suggestions, but nothing works.
Here's a few notes about what we're seeing.
This issue occurs occassionally in SQL Server Management Studio itself (doing any kind of database activity... getting a list of tables in a database, having a look at a Stored Procedure, etc)
It also happens in Visual Studio 2010 itself, when it is trying to get data from the servers (e.g. when creating a .dbml file, etc)
It also sometimes happens in our .Net (ASP, WPF, Silverlight) applications.
Our SQL Server 2005 & 2008 servers are all based on virtual machines in data centres around the world, and we see sometimes this error on each of them. But most of the time, they all work absolutely fine.
When the error does occur, we can just "retry" what caused the error, and then it'll work fine.
We think.. if we have an IIS Web Server in a data centre in a particular city, and it accesses a SQL Server in the same data centre, then we don't see the issue.
We think.. if we connect to the servers, and specify the UserID and Password to use, it causes this error much more frequently than if we just use Active Directory authentication.
Put all that together, and it sounds to me like some kind of network issue.
But can anyone suggest what to look for ?
This isn't a bug in our .Net applications, as even SQL Server Management Studio "trips up" with this error.
It's baffling us.
Just in case anyone else hits this issue, we finally found the solution.
Our company uses Riverbed software to compress data, when it's being passed between locations, and this was somehow causing some connections to get dropped.
Our IT gurus found a configuration setting which finally fixed this issue.
I believe there's a setting in there to turn off compressing results from SQL Server (or something like that). That fixed it for us.
It could be any number of network issues. ANYTHING that prevents the code from reaching the server even for the few miliseconds it takes to make one query.
it could also be the result of a failover. When we went from a single SQL Server to a clustered environment, we'd see this happen during a failover. In this case, it turned out to be our Connection Pooling. In essence, the SQL cluster has a controller and two servers behind it. A and B.
Say our web app is using server A just fine, Connection pooling creates a connection on both sides. The server is aware of it, and the web app is aware of it. Once the cluster fails over to the second server, the web app is aware of the connection but server B is not, so we get an error.
The point is, any possible cause of network issues imaginable may be the cause. DOS attacks on the server, man-in-the middle attacks intercepting and changing traffic. Someone trips on an ethernet cable and it's loose in the jack. You name it, if it can cause a connection issue, it could be the cause.
Your issue also sounds like one we had recently - we also have a virtual environment, wih software that moves VMs from one host to another as needed for load balancing. Every so often, we'd get bombarded with the same error. It turned out to be an issue with the NIC drivers on one of the hosts, so whenever a VM moved to that particular host, errors would occur.
It's really not a programming issue. It's an environment issue, and you need trained professionals with direct access to your environment to research and resolve this.
My problem was that I was inadvertently using a wireless network to connect to our network because the Ethernet cable was faulty. This after repairing SQL Server, running a Winsock reset as recommended elsewhere ...
I am experiencing the same issue and our app interfaces with a several Azure SQL DBs. I believe (same as you) I do not have a bug in the C# code to cause this issue. We've solved it by a simple for loop containing an extra attempts to try to connect to the Azure SQL again if the previous attempt fails and then run the query.
Most of the time everything runs fine but sometimes we can see the loop kicked-in and on the 2nd or 3rd time it executed properly without the below mentioned error. After that we see in the log file the error below for all the unsuccessful attempts:
A connection was successfully established with the server,
but then an error occurred during the login process. (provider: TCP
Provider, error: 0 - An existing connection was forcibly closed by the
remote host.)
Even though this is a less-then-pretty solution, it allowed us to run our app without interruptions. I know you've mentioned that trying to connect again (to introduce some connection-failure tolerance) solves the problem and unfortunately this is the only correct solution I found so far as well.
I should mention that we have tried many debugging strategies to figure this out. Right now it all points to the availability of the database we are trying to connect to i.e.: It happens if the number of allowed DB connections is exceeded. (or so it seems at this time)
Turn off your VPN
My Problem fixed by turn off VPN
It was happening in our code when we were opening the dbconnection for oracle and were passing DBtype as SQL in our database object.
in my case - the error was Microsoft first suggestion:
Client is connecting with an unsupported version of the SQL Server Native Client.
In our case, We got this error when we updated sql server to sp3. We were not able to connect to the database from SSIS package.
We updated the native client and configurations. We were able to connect.
link to download the native client - https://www.microsoft.com/en-us/download/confirmation.aspx?id=50402
Link for configurations settings and further troubleshooting - https://learn.microsoft.com/en-us/previous-versions/sql/sql-server-2008-r2/ms187005(v=sql.105)
Hope it helps.
Cheers!
Had the same type of issue. In my case it was a bit more complicated... I could connect to “ServerA” from “ServerB” via SSMS, but it would fail with sqlcmd. The error was the same:
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : TCP Provider: An existing connection was forcibly closed by the remote host.
I could also connect from “ServerC” with both SSMS and sqlcmd. The following are the versions on the VMs:
ServerA: Microsoft Windows Server 2012 R2 Datacenter / Microsoft SQL Server 2012 (SP3-CU10) (KB4025925) - 11.0.6607.3 (X64)
ServerB: Microsoft Windows Server 2012 R2 Datacenter / Microsoft SQL Server 2012 - 11.0.5058.0 (X64)
ServerC: Microsoft Windows Server 2012 R2 Datacenter / Microsoft SQL Server 2012 (SP3-CU10) (KB4025925) - 11.0.6607.3 (X64)
Bottom line was the “unsupported version”. I noticed a mismatch of “sqlncli11.dll” between ServerC and ServerB, so I copied it to the System32 folder. After this, sqlcmd worked like a charm. Below were the versions in my case:
Failed:
FileVersion: 2011.0110.5058.00
ProductVersion: 11.0.5058.0
Worked:
FileVersion: 2011.0110.6607.03
ProductVersion: 11.0.6607.3
I was working on 2 projects at the same time (on 2 different machines) and both used SQL Server.
When i disconnected SQL with 1 machine the errorMessage went away. Probably you can mess around with IP-adresses too to fix the problem.
In my case I was seeing this error intermittently from a .Net application connecting to a SQL server located in the same server room. It turned out that some of the databases had auto close turned on which caused the server to close the connections in the pool. When the application tried to use one of the pool connections that had been closed, it would throw this error and I saw a log message on the SQL server that the database it was trying to connect to was being started. Auto-close has now been turned off on those databases and the error hasn't been seen since.
Also, having auto-close on is the default behavior for SQL Express databases and these were originally created on an Express instance during testing before being migrated to the production server where we were seeing the errors.
this answer is for those how have this problem with Azure Sql server database.
It happens when you reach mat pool
first remove Persist Security Info=False from connection string
second check your database plan in azure portal and increase the PTUs of your database plan.
In SSMS "Connect to Server" screen click Options, then on "Connection Properties" TAB change "Network protocol" to "Named Pipes"
Try this -
Click Start, point to All Programs, and click SQL Server Configuration Manager.
Click to expand SQL Server Network Configuration and then click Client Protocols.
Right-click the TCP/IP protocol and then click Enable.
Right-click the Named Pipes protocol and then click Enable.
Restart the SQL server service if prompted to do so.
I have had this issue a couple of time already, and I've fixed by reducing the MTU size. Often 1350, 1250, etc on my network interface.

IP Access to SQL Server

We have a Windows VPS server using SQL Server 2005 for our e-commerce site.
A while back we were suffering from attempts to access the database remotely so someone made changes so that only the IP of the server itself could access data. That was about 18 months ago and everything has been fine since.
However, we now have a second site (hosted on another VPS) that needs to access the same database and I can't get in contact with the person who made the original changes.
I know he was working in the SQL Server Management tool when he made the changes, can anyone point me in the correct direction.
Thanks.
SQL Server 2005 came locked down by default. Rather than SSMS, it also installs the SQL Server 2005 Surface Area Configuration tool, which has a Remote Connections setting where you can limit it to Local connections only.
You may also like to check any firewall on the server, which will have to allow Port 1433 (or different if changed from the default) TCP access from whichever machines you want to access it.
He might have turned the TCP/IP protocol off. In this case only the localhost can access the database. This link describes the procedure for sql server express, but the idea is the same

Can't connect to SQL Server 2008 - looks like Shared Memory problem

I am unable to connect to my local instance of SQL Server 2008 Express using SQL Server Management Studio.
I believe the problem is related to a change I made to the connection protocols. Before the error occurred, I had Shared Memory enabled and Named Pipes and TCP/IP disabled. I then enabled both Named Pipes and TCP/IP, and this is when I started experiencing the problem.
When I try to connect to the server with SSMS (with either my SQL server sysadmin login or with windows authentication), I get the following error message:
A connection was successfully established with the server, but then an error occurred during the login process. (provider: Named Pipes Provider, error: 0 - No process is on the other end of the pipe.) (Microsoft SQL Server, Error: 233)
Why is it returning a Named Pipes error? Why would it not just use Shared Memory, as this has a higher priority order in the list of connection protocols? It seems like it is not listening on Shared Memory for some reason?
When I set Named Pipes to enabled and try to connect, I get the same error message.
My windows account is does not have administrator priviliges on my computer - perhaps this is making a difference in some way (as some of the discussions in this post about an "SuperSocketNetLib\Lpc" registry key seems to suggest).
Had the same problem. Here is what solved it for me:
Open SQL Management Studio
Connected through the admin account I used to setup the instance
Selected the server from Object Explorer
Right mouse click properties
Server properties opens
Go to Security
Changed it from Windows Authentication mode to SQL Server and Windows Authentication Mode
I didi everything google teaches and can't connect with TCP/IP successfully. Then I do these steps to make it work in my home computer:
step 1. Enable TCP/IP in SQL Server Network Configuration for your DB instance.
step 2. Choose properties of TCP/IP and click IP Addresses tab.
step 3. Inactive all IP address except 127.0.0.1.
step 4. Set TCP Port to 1433 in 127.0.0.1 and IPALL.
step 5. Restart sql server service.
step 6. Connect it with TCP/IP using '127.0.0.1\SQLEXPRESS,1433' in Toad for SQL Server freeware, it works!
step 7. Connect it with same server string in php, it works!
step 8. If you need read Chinese string into php program as I am, download MS SQL Server driver for PHP(Believe me, don't even try php_mssql stuff, it'll drive you crazy with Chinese data). For PHP 5.2x, use ts_VC6 version. For 5.3X, use ts_VC9 version (especially when in Win7).
step 9. Edit php.ini (For Appserv, it's under C:\Windows7; for WAMPserver 2.2, it's under c:\wamp\bin\php\php5.3.8), find extension=... line groups. Add 'extension = specific sql erver driver dll filename you are to use.
step 10. Unzip the file downloaded in step 8 and copy the specific dll (or copy all) to php extension directory (you can find it in php.ini's extension_dir=... line). For Appserv, you better copy it to c:\windows\system32, too(Don't ask me why?).
step 11. restart apache service of Appserv or restart Wampserver.
Now you can use TCP/IP to connect with SQL Server 2008 and you can read utf-8 string (in my case) into php program correctly.
Hope this helps those who are deperately looking for this solution, as i am.
Since now you cannot connect to SQL Server to disable named pipes, you have to force a TCPIP connection.
Here's how:
click on START / RUN then run the cliconfg.exe utility. In this, create an alias for your server (you can use the same name) and put the default for TCPIP
That should force TCPIP over Named Pipes and maybe get you connected.
Try connecting to the alias name that you used in CliConfg and it will now connect using TCPIP.
I had this exact same problem. I'd try connecting as ASHWHVM004\SQLEXPRESS and I'd get a connection failed message. If I explicitly requested Shared Memory, it'd work fine. Shared Memory, Named Pipes, and TCP/IP were all enabled.
I seemingly "fixed" it by doing the following:
I opened up Sql Server Configuration Manager and drilled down to SQL Server Network Configuration > Protocols for SQLEXPRESS.
I disabled everything except Shared Memory.
I restarted the SQLEXPRESS service instance and tried connecting as before. It worked fine.
I enabled TCP/IP and Named Pipes and restarted the SQLEXPRESS service instance and tried connecting as before. It worked fine.
Either I did something else during this process to fix it that I don't recall, or the act of disabling and re-enabling caused some twiddly bit to get flipped back the right way.
Good luck!

Resources