For me the issue was that the DNS record was wrong…
The following, which proved very helpful, is largely taken from this blog post.
This error message is actually pretty specific and the solution quite simple.
You get this error message only if you are trying to connect to a SQL Server named instance. For a default instance, you never see this because even if we failed at this stage (i.e. error locating server/instance specified), we will continue to try connect using default values, e.g default TCP port 1433, default pipe name for Named Pipes.
Every time a client makes a connection to SQL Server named instance, we will send a SSRP UDP packet to the server machine UDP port 1434. We need this step to know configuration information of the SQL instance, e.g., protocols enabled, TCP port, pipe name etc. Without this information the client does not know how to connect and it fails with this error message.
In a word, the reason that we get this error message is the client stack could not receive SSRP response UDP packet from SQL Browser. In order to isolate the exact issue follow these steps:
-
Make sure your server name is correct, e.g., no typo on the name.
-
Make sure your instance name is correct and there is actually such an instance on your target machine. (Be aware that some applications convert \ to ).
-
Make sure the server machine is reachable, e.g, DNS can be resolve correctly, you are able to ping the server (not always true).
-
Make sure the SQL Browser service is running on the server.
-
If the firewall is enabled on the server, you need to put sqlbrowser.exe and/or UDP port 1434 into exception.
There is one corner case where you may still fail after you checked steps 1 to 4. It also may happen when:
- your server is a named instance on cluster or on a multi-homed machine
- your client is a Vista machine with Firewall on.
A tool which could prove useful (it did for me) is PortQry. If this command returns information and it contains your target instance, then you can rule out possiblity 4) and 5) above, meaning you do have a SQL Browser running and your firewall does not block SQL Browser UDP packet. In this case, you can check other possible issues such as an incorrect connection string.
As a final note, the error message for the same issue when you use SNAC is:
[SQL Native Client]SQL Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF].
Microsoft recently released a guided walk through that can serve as a one stop shop to troubleshoot a majority of connectivity issues to SQL Server: Solving Connectivity errors to SQL Server
5 / 5 / 3 Регистрация: 05.03.2013 Сообщений: 220 |
|
1 |
|
19.07.2014, 21:18. Показов 90940. Ответов 8
Помогите пожалуста исправить При установлении соединения с SQL Server произошла ошибка, связанная с сетью или
0 |
1242 / 1052 / 293 Регистрация: 07.03.2012 Сообщений: 3,245 |
|
22.07.2014, 10:07 |
3 |
типичная ошибка при неверной строке соединения. Покажите, как соединяетесь
1 |
mixon-21 5 / 5 / 3 Регистрация: 05.03.2013 Сообщений: 220 |
||||
22.07.2014, 17:14 [ТС] |
4 |
|||
0 |
1242 / 1052 / 293 Регистрация: 07.03.2012 Сообщений: 3,245 |
|
22.07.2014, 17:36 |
5 |
mixon-21, Примерно так должно быть: CompName\sqlexpress
0 |
5 / 5 / 3 Регистрация: 05.03.2013 Сообщений: 220 |
|
22.07.2014, 18:32 [ТС] |
6 |
management studio откройте, соединитесь с сервером, слева в верхнем углу будет прописано то, что должно быть в Data Source Примерно так должно быть: CompName\sqlexpress МИША-ПК(SQL Server10/50.1600-Миша-ПК\Миша) Оно???
0 |
1242 / 1052 / 293 Регистрация: 07.03.2012 Сообщений: 3,245 |
|
22.07.2014, 18:53 |
7 |
МИША-ПК(SQL Server10/50.1600-Миша-ПК\Миша) не думаю что такое сочетание скобок и разных видов слешей ему понравится Добавлено через 50 секунд
0 |
mixon-21 5 / 5 / 3 Регистрация: 05.03.2013 Сообщений: 220 |
||||
22.07.2014, 23:26 [ТС] |
8 |
|||
Добавлено через 4 часа 6 минут
выводит ошибку. как правильно???
Заданное приведение является недопустимым.
1 |
Alex_student 18 / 18 / 8 Регистрация: 10.02.2013 Сообщений: 250 |
||||
23.07.2014, 10:43 |
9 |
|||
К сожалению нет времени посидеть над вашим кодом, но посмотрите код из моего старого проекта, насколько помню работал без вопросов:
1 |
Добрый день!
Прошу помощи в решении следующей проблемы.
Есть корпоративная сеть из нескольких машин с разрядностью как 32, так и 64. Авторизация происходит по доменным учетным записям.
Установила на 64-разрядную машину 2 пользовательских инстанса SQL Server 2008 R2: один со смешанным режимом авторизации (пользователь sa), другой с проверкой подлинности Windows.
1. Sql Browser запущен.
2. TCP IP включен.
3. Брандмауэр windows Отключен.
4. В Sql Server Management Studio стоит галочка: allow remote connections.
Локально все подключается нормально. Второй 64-разрядный комп в сети также спокойно подключается к инстансам.
32-разрядные компы же выдают следующую
ошибку:
При установлении соединения с SQL Server произошла ошибка, связанная с сетью или с определенным экземпляром. Сервер не найден или недоступен. Убедитесь, что имя экземпляра указано правильно и что на SQL Server разрешены удаленные соединения. (provider:
SQL Network Interfaces, error: 26 — Ошибка при обнаружении указанного сервера или экземпляра)
Подскажите, в чем может быть проблема?
не могу разобраться, выдает ошибку
При установлении соединения с SQL Server произошла ошибка, связанная с сетью или с определенным экземпляром. Сервер не найден или недоступен. Убедитесь, что имя экземпляра указано правильно и что на SQL Server разрешены удаленные соединения. (provider: SQL Network Interfaces, error: 26 — Ошибка при обнаружении указанного сервера или экземпляра
это не еррор, это как предупреждение
class Program
{
static void Main(string[] args)
{
string connectionString = @"Data Source=.\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True";
string sqlExpression = "SELECT * FROM Users";
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
SqlCommand command = new SqlCommand(sqlExpression, connection);
SqlDataReader reader = command.ExecuteReader();
if (reader.HasRows) // если есть данные
{
// выводим названия столбцов
Console.WriteLine("{0}\t{1}\t{2}", reader.GetName(0), reader.GetName(1), reader.GetName(2));
while (reader.Read()) // построчно считываем данные
{
object id = reader.GetValue(0);
object name = reader.GetValue(1);
object age = reader.GetValue(2);
Console.WriteLine("{0} \t{1} \t{2}", id, name, age);
}
}
reader.Close();
}
Console.Read();
}
}
Okay so a lot of people have posted a similar question, however I don’t seem to be able to find a solution to my problem in any of them. So this is my situation.
Yesterday I was working with my SQL Server Express through SQL Server Management Studio. I close my projects as I’ve done multiple times before and then this morning when I tried to connect again with the tool is gives me this error:
TITLE: Connect to Server
Cannot connect to .SQLExpress.
ADDITIONAL INFORMATION:
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)
I think my main question here is if there is a solution to this problem, or if I have to install SQL Server Express all over again?
PS: Here are some system stats. I’m working on a Windows 10 machine, and the SQL Server Management Studio version is 2014.
This issue also confused me a few days, after the IT guy changed some security settings on the SQL Server.
I have an EntityFramework for the Web application and for a desktop application.
After I changed some settings on the SQL Server, the Web application comeback to work, but the desktop still facing issue. But I used the same connection string for both applications, it make no sense one is working but the other doesn’t.
Then I searched a lot until I found someone saying here it is needed to add port number 1433 after the $ServerName$DatabaseInstanceName,1433
.
After I added it, the exception became:
System.Data.SqlClient.SqlException: Login failed for user
‘domainname-PC$’
Then I found this link. It says to add Trusted_Connection=False;
.
The whole connection string should be like:
data source=XXXXXSQLSERVER,1433;initial catalog=XXXDB;user id=UserID;password=PWD;Trusted_Connection=False;MultipleActiveResultSets=True;
Hope this answer will help the ones out off Generic exception:
Error: 26-Error Locating Server/Instance Specified
Добрый день!
Прошу помощи в решении следующей проблемы.
Есть корпоративная сеть из нескольких машин с разрядностью как 32, так и 64. Авторизация происходит по доменным учетным записям.
Установила на 64-разрядную машину 2 пользовательских инстанса SQL Server 2008 R2: один со смешанным режимом авторизации (пользователь sa), другой с проверкой подлинности Windows.
1. Sql Browser запущен.
2. TCP IP включен.
3. Брандмауэр windows Отключен.
4. В Sql Server Management Studio стоит галочка: allow remote connections.
Локально все подключается нормально. Второй 64-разрядный комп в сети также спокойно подключается к инстансам.
32-разрядные компы же выдают следующую
ошибку:
При установлении соединения с SQL Server произошла ошибка, связанная с сетью или с определенным экземпляром. Сервер не найден или недоступен. Убедитесь, что имя экземпляра указано правильно и что на SQL Server разрешены удаленные соединения. (provider:
SQL Network Interfaces, error: 26 — Ошибка при обнаружении указанного сервера или экземпляра)
Подскажите, в чем может быть проблема?
SQL Server Error 26 and SQL Server Error 40 appear when you try to connect to SQL Server. We will troubleshoot and try to fix them in the same article as both are related to connection issue. We recommend to use the below solutions for the both errors and to try to localize the problem.
The error Messages:
(provider: SQL Network Interfaces, error: 26 – Error Locating Server/Instance Specified)”
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)
“ Named Pipes Provider Error: 40 – Could not open a connection to SQL Server“.
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)
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 the SQL Server is configured to allow remote connections. (provided: Named Pipes Provider, error: 40- Could not open a connection to the SQL Server) (Microsoft SQL Server, Error: 2).
sql server error 26
SQL Server Error 26 and SQL Server Error 40
What is SQL Server Error 26?
You will get this error message while trying to connect to a SQL Server named instance and not when you use default instance. The client stack could not receive SSRP response UDP packet from SQL Browser.
How to fix Error 26 on SQL Server?
- Recheck the server name for any error and fix it
- Check the instance name for any error
- Check if SQL Server browser is running
- Control if this instance exist on server
- Ping the server and check if DNS can be resolved correctly
What is SQL Server Error 40?
This error appears mostly when SQL Server does not allow remote connections, Firewall Settings or TCP/IP is not enabled. We will explain below all those in order to troubleshoot easy.
Read also other SQL Server Helping Posts:
- How to fix SQL Server Error 229
- Fix SQL Server Error 233
- SQL Server Error 17002
How to fix error 40 on SQL Server?
- Check SQL Server is running
- Make sure that Allow Remote Connections is enabled on sql server properties
- Check if TCP/IP is enabled
- Configure to allow SQL Server in Firewall Settings
- Check for working fine SQL Server Browser
- Make sure that you can ping the SQL Server
Below we will explain the above steps in long way for better understanding and easy fix of SQL error 26 and sql error 40.
1. Check if SQL Services are running
Hint! If you are running SQL Server by using an instance name and you are not using a specific TCP/IP port number in your connection string, you must enable the SQL Server Browser service to allow for remote connections.
How to check if SQL Server Service is running?
- Go to SQL Server Configuration Manager > SQL Server Services
- Find the service SQL Server (MSSQLSERVER) if default or the name of your instance
- Check if is running – should be running state with a green indication
Using Windows Command Prompt
sc query mssqlserver
For named instance name use below by by replacing instancename with the actual SQL Server instance name.
sc query mssql$instancename
How to check if SQL Server Browser is running?
- Navigate to SQL Server Configuration Manager > SQL Server Services
- Find the SQL Server Browser Service
- Check if it is configured to start automatically and is started – should be with a green indication
Using Windows Command Prompt
sc query sqlbrowser
Check if SQL Server Service
2. Try to Flush DNS
How to flush DNS?
- Click Start Button
- Type CMD and press enter
- Type this into the black window that appears: ipconfig /flushdns and press enter.
Fluish DNS
3. Make sure that allow Remote Connection is enabled
Check if remote connections is allowed for applications/client. This option need to be allowed to establish connections and perform operations on the server. Often this is the reason of SQL Server Error 26 and SQL Server Error 40.
How to check if the remote connection is enabled?
- Open ‘SQL Server Management Studio’
- Right click on database name and select ‘Properties’
- In ‘Properties’ window, select ‘Security’, enable `SQL Server and Windows Authentication mode` and click `OK`.
- Now restart the SQL server.
Allow Remote Connections
4. Check Firewall
Check the firewall status for any troubles:
- Open ‘Control Panel’ and after that ‘Windows Firewall’.
- Select ‘Change Settings’ In ‘Windows Firewall’,
- Add an exception for port ‘1434’ and name it ‘SQL Server’
- Enable by clicking on the checkbox
5. Connection String
This solution is on cases when you are using connection string and are you writing it wrongly. For example connection string used by .NET framework:
Server=serverAddress;Database=dbName;User Id=username;
Password=password;
- Check for each parameter passed in the connection string for any typographical errors.
- Control the validity of the username/password.
- Confirm if the given database exists.
6. TCPIP Protocol
This solutions can work when you have mix of default and named instance or named instances only.
How to Enable TCP/IP port?
- Open SQL Server Configuration Manager
- Click on SQL Server Network Configuration and click on Protocols for Name
- Right-click on TCP/IP
- Click Enable
- Restart your SQL Server instance
Enable TCP-Ip port
If you want to use a static port for your instance (instead of dynamic that changes after every restart) you can change it here.
- Open Properties for TCP/IP protocol
- Go to IP Addresses tab
- Scroll down to IPAll section
- Remove 0 value from TCP Dynamic Ports
- Specify your port in TCP Port
You can use this port to connect to your instance by providing <servername>,<port> or <IP>,<port> as Server Name (yes, there is a comma, not a colon).
TCP-Ip static port
Conclusion:
We have explained some solutions to fix SQL Server Error 26 and SQL Server Error 40 and hope that you find the fix on those solutions. The both errors are included on the same article because they have almost the same troubleshoot. If you have any other solution worked for you comment below and we will try to include it on our article.