Similar to another couple of questions I've seen, I'm in the dark place of having no choice other than to connect to MSSQL from Django.
I'm intermittently (but around 50% of the time, the rest it works fine) getting the error;
django.db.utils.Error: ('[08S01] [Microsoft][ODBC Driver 13 for SQL Server]TCP Provider: Error code 0x274c (10060) (SQLGetData)')
Note, I also get this one sometimes;
django.db.utils.Error: ('08S01', '[08S01] [Microsoft][ODBC Driver 13 for SQL Server]TCP Provider: Error code 0x68 (104) (SQLGetData)')
I think it's network related, I've previously tried swapping out pyodbc versions, swapping between FreeTDS and Microsoft driver for unix, and trying pyodbc and pyodbc-azure.
The machines in question are Vagrant boxes on a private network with fixed IPs (Ubuntu 16.04 and Windows 8), SQL Server is SQL Server Express 2016.
I can't even work out how to find a more detailed log on the Windows side to work out why/how it keeps dropping/closing the connection. Note - I've looked in the SQL Server and Windows event logs and they don't seem to be picking anything up.
Here are some useful links based on the error codes logged:
10060
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)
Generally, you can fix this by navigating to the SQL Server instance and making sure remote connections are allowed. There is a configuration setting in SSMS for this. You also want to make sure the server is set up to use integrated mode security. i.e - windows/ad credentials and sql server credentials. You can define a SQL server user not bound to a user windows identity.
Related
We have a MS-Access front application using data from a SQL server back-end. We are using ODBC connections for the data communications. The application randomly getting frozen or crashes giving different errors as attached below which very likely seems to be issues related to ODBC connection. Problems can be recreated by running different queries in quick successions.
SQL Server Version: SQL Express 14.0.3356.20
Access Version: Microsoft 365 Apps for Business Version 2011 (Build 13426.20204)
Most common error codes:
10054, 10060, 3146, 3151
ODBC Data Source Type: System DSN
ODBC Driver: ODBC Driver 17 for SQL Server (Version 2017.176.01.01)
Example Connection String for a linked table: ODBC;Description=Test Description;DRIVER=ODBC Driver 17 for SQL Server;SERVER=MY-SERVER;UID=MyUser;Trusted_Connection=No;APP=Microsoft Office;DATABASE=TestDatabase;;TABLE=dbo.TableName
Largest Table Size: 53000 records (Doesn't really matter, fails for even smaller queries, but if you try faster getting results from different queries you can break it)
Error1 Error2 Error3
We have gone through hundres of searches/articles about these and applied the fixes listed below, but still couldn't get the problem solved.
We have tried below solutions as of now which didn't help.
Created firewall rules (Inbound - TCP Port 1433, Outbound - TCP all
ports)
Added TCP Port 1433 - TCP/IP protocol
Enabled Namepipe
Updated SQL Server Express from 14.0.3335.7 to 14.0.3356.20
Made IP4 and IP6 are both enabled
Enabled and checked ODBC Trace Logs
Checked Windows Event Logs
Hope I have included everything that might be useful to get some help resolving this issue.
Note: Not sure if it's related, but the SQL Server itself (in the backend) giving the below error in rare occasions if it helps.
Connection Timeout Expired. The timeout period elapsed while attempting to consume the pre-login handshake acknowledgement. This could be because the pre-login handshake failed or the server was unable to respond back in time. The duration spent while attempting to connect to this server was - [Pre-Login] initialization=29278; handshake=26244; (.Net SqlClient Data Provider)
Thanks everyone who tried to help. This issue has now been fixed.
For anyone who will come here in future looking for a solution for a similar issue, below is what worked for us.
Added a new instance of SQL Server 2019 (in the same virtual machine
which 2017 sits on)
Enabled UDP Port 1434
Changed virtual port from blank to zero
2017 was still crashing before taking offline with the same settings.
No issues with the 2019 version.
We have an older machine that hosts a bunch of test databases. It was working fine for years. One day a few months ago, we could no longer open SQL Admin on that machine. When you tried, you get the dreaded:
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)
Note that we are running everything on this one machine. We are not trying to connect over the network from another machine. I tried variations on MS's page and on various SO threads on the topic:
the firewall is off
the server is running, as is the name service
it is configured for remote connections
we've rebooted it
Again, this was all working fine, and we changed nothing on that machine. I suppose a Win update may have occurred.
On a lark, today I tried making a new DSN to the same server, using SQL Client 11. It saw the server in the combo (took a while), and the test connection worked fine. But SQLSM still fails!
Does anyone know what connection type the Native Client would use, and what that driver uses to populate the server list?
My suspicion is that something is wrong with the named pipes service. If ODBC uses named pipes, then I'm a bit stumped.
I have configured a SQL Server 2016 alias following this post and it was working, but suddenly it stopped working.
Error message:
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 wait operation timed out.) (.Net SqlClient Data Provider)
I created the alias using the SQL Server Configuration Manager and created it in the 32 and 64bit:
When I go to the Protocols for SQL Server Express, all of them are enabled, thus TCP/IP is enabled. Also, the SQL Server Browser service is running.
Looking at the system log there is no relevant message about it, so I'm a bit lost about what could be causing it to stop working. My OS is Windows 10 Pro.
Would you have any clues to help me solve it? Thanks for any help
Check that the SQLEXPRESS instance's port number hasn't changed, which is likely after a reboot or service restart.
Regarding the use of instance aliases, this is pretty much useless if you're also using dynamic ports for this very reason. To me it's more cumbersome to maintain this configuration than it is to maintain a connection string in your program IMHO.
I have SQL Server 2008 R2 installed on my PC running Win 7 x64. I used to use it every day with a connection from management studio (Windows Authentication). But, for some reason, management studio is not accepting my connection anymore after I installed DB2 on the same PC.
I know that the instance is not broken since I am able to connect well with Visual Studio 2010 where I also tried creating new DB, inserting records etc.
How do I mend this problem with management studio? How might installing DB2 have affected Management Studio?
I am getting following error:
TITLE: Browse Server for Database
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://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=-1&LinkId=20476
It's not an authentication issue, as you would get a different error. If this is a named instance, you need to ensure the SQL Server Browser service is started.
I'm guessing you also have TCP/IP protocol enabled?
I don't know much about DB2 but maybe there is some conflict with the ports used. By default SQL Server uses 1433 for the default instance, and 1434 for SQL Browser to dynamically allocate a port for named instances. Check these to make sure they are still good.
Make sure that you have port opened on target server.
Use Telnet (install from Control Panel -> Turn Windows features On of Off)
>telnet <server-ip/name> 1433
or network scanner from nmap.org
>nmap -sT -r -n -vv -p1433 <server-ip/name>
I developed a .net application that depends on a sql server database, the database was on the local machine used for development of the application.
When I moved the database to a remote machine and changed the connection string I got the following error:
An error has occurred while establishing a connection to the server when connecting to SQL server 2005, this failure may be caused by the fact that under default settings SQL server does not allow remote connection. ( provider: Named Pipes Provider, error: 40 – could not open a connection to SQL server. )
This error occurs only from XP machines but it works fine from Win. 7 Machines with the same connection string:
connectionString="Data Source=ot;Initial Catalog=sp_warehouse;User ID=fu;Password=bar"
I tried the following to troubleshoot the problem:
- Disabled Named Pipes service from the server.
- Added an exception in the server firewall for the SQL Server port 1433
- Disabled the firewall on the server completely
- Added this parameter in the connection string: Network Library=DBMSSOCN;Persist Security Info=True
Each time I try something I get the same result, win. 7 machines work fine but XP machines don't.
Note: There's another application works from XP machines that uses another database on the same SQL Server and it's working fine.
Make sure the SQL Browser is enabled and running on your remote machine. You'll probably want to leave named pipes enabled.