无法连接到 SQL Express“错误:26-错误定位指定的服务器/实例”

发布于 2024-11-17 03:39:55 字数 884 浏览 2 评论 0原文

我对一台运行 SQL Server 2008 R2 Express 的特定机器感到手足无措。

  • Windows 防火墙配置为允许入站 TCP 和 TCP 入站UDP 1433、1434。Windows
  • 防火墙配置为允许出站 TCP 和 1434。任何端口上的 UDP。
  • 当前没有其他软件 AV/FW 正在运行。

当我尝试连接到 xxx.xxx.xxx.xxx\sqlexpress 时,超时并出现以下错误:

标题:连接到服务器

无法连接到 xxx.xxx.xxx.xxx\SQLEXPRESS。

其他信息:

建立与 SQL Server 的连接时发生与网络相关或特定于实例的错误。找不到服务器或无法访问服务器。验证实例名称是否正确以及 SQL Server 是否配置为允许远程连接。 (提供程序:SQL 网络接口,错误:26 - 定位指定的服务器/实例时出错)(Microsoft SQL Server,错误:-1)

我已检查服务器上是否允许远程连接。

我已确认在 SQL Server 配置中启用并配置了 TCP/IP,以允许外部 IP 上的连接到 1433。

我还从本地计算机使用了 Wireshark,并且可以看到发送到远程服务器的 1433 UDP 请求。

但是在远程服务器上使用 Wireshark 显示没有 1433 UDP 的入站连接请求或来自我的外部 IP 的任何内容(从结果中过滤到远程 RDP)。

这让我认为这是防火墙问题。

该服务器由外部公司托管,该公司可以控制我们服务器前面的 PIX。

我需要自己尽可能地解决这个问题,因为托管公司不知道他们在做什么。

I am at an loose end with one particular box that is running SQL Server 2008 R2 Express.

  • Windows Firewall is configured to allow inbound TCP & UDP 1433, 1434.
  • Windows Firewall is configured to allow outbound TCP & UDP on any port.
  • No other software AV/FW is currently running.

When I try to connect to xxx.xxx.xxx.xxx\sqlexpress, it times out with the following error:

TITLE: Connect to Server

Cannot connect to xxx.xxx.xxx.xxx\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 have checked that remote connections are allowed on the server.

I have confirmed TCP/IP is enabled and configured in SQL Server Configuration to allow connections on the external IP to 1433.

I have also used Wireshark from my local machine and I can see requests for 1433 UDP going to the remote server.

But using Wireshark on the remote server shows no inbound connection requests for 1433 UDP or anything from my external IP (with filtering to remote RDP from results).

This makes me think it is a firewall issue.

The server is hosted by an external company who have control over the PIX in front of our server.

I need to troubleshoot this as much as possible myself as the hosting company have no clue what they are doing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(20

泪是无色的血 2024-11-24 03:39:55

我遇到了类似的问题,通过转到“SQL Server 配置管理器”并确保“SQL Server 浏览器”配置为自动启动并启动来解决该问题。

我在这个论坛帖子的答案中遇到了这个解决方案:
<一href="http://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/8cdc71eb-6929-4ae8-a5a8-c1f461bd61b4/ ">http://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/8cdc71eb-6929-4ae8-a5a8-c1f461bd61b4/

我希望这对那里的人有帮助。

I had a similar problem which was solved by going to the "SQL Server Configuration Manager" and making sure that the "SQL Server Browser" was configured to start automatically and was started.

I came across this solution in the answer of this forum post:
http://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/8cdc71eb-6929-4ae8-a5a8-c1f461bd61b4/

I hope this helps somebody out there.

逆光下的微笑 2024-11-24 03:39:55

windows+R打开RUN窗口

services.msc 

找到SQL Server(SQLEXPRESS)右键单击它并启动服务
然后检查

press windows+R open RUN Window

services.msc 

find SQL Server(SQLEXPRESS) right click on that and start the service
then check

淡紫姑娘! 2024-11-24 03:39:55

转到SQL Server 配置管理器> SQL Server 服务>>在右侧窗口中显示所有可能停止的服务器。如果您使用“SQLEXPRESS”,那么,
右键单击 SQL Server(SQLEXPRESS) 并启动。尝试连接服务器后...我遇到了同样的问题,但我通过以下步骤解决了。

Go to SQL Server Configuration Manager > SQL Server Services > In Right Side window show all the servers which may stop. If you are using "SQLEXPRESS" then ,
Right click on SQL Server(SQLEXPRESS) and start. After try to connect server... I had same problem but I resolved by these steps.

江挽川 2024-11-24 03:39:55

以下是解决连接问题的简单方法:

  1. 使用文本编辑器创建一个名为 test.udl 的空文件
  2. 双击文件 test.udl,然后指定连接属性
  3. 单击“测试连接”按钮。

Here is a simple method to troubleshoot connection issues:

  1. Create an empty file called test.udl using a text editor
  2. Double click the file test.udl, then specify your connection properties
  3. Hit the "Test Connection" button.
各自安好 2024-11-24 03:39:55

我最近遇到了同样的问题,但我使用的是 Windows 10 Technical Preview Build 10041 和 SQL Server 2014(高级)。

遵循上面相同的建议:

特别是,我的问题是我没有在 Sql 中启用 TCP/IP
服务器配置管理器->SQL Server 网络
配置 -> SQLEXPRESS 协议。

打开它后,您必须转到“IP 地址”选项卡,对我来说,
将 IPAll 更改为 TCP 端口 1433 并删除 TCP 动态端口
价值有效。

按照其他步骤确保 1433 正在侦听(使用 netstat -an
确保 0.0.0.0:1433 正在监听。),并且您可以 telnet 到
来自客户端计算机的端口。

最后,我同意从中删除 \SQLEXPRESS 的建议
连接。

并且---->最后一行很重要!它看起来像是 Windows 10 特定的;从连接字符串中删除 \SQLEXPRESS。令人沮丧的是,SQL Management Studio 使用连接字符串(完整或短)连接得很好,但 Visual Studio 只接受不带 \SQLEXPRESS 的连接字符串。

I recently encountered the same issue however I am using Windows 10 Technical Preview Build 10041 and SQL Server 2014 (Advanced).

Follow the same advice from above:

In particular, my problem was that I did not enable the TCP/IP in Sql
Server Configuration Manager->SQL Server Network
Configuration->Protocols for SQLEXPRESS.

Once you open it, you have to go to the IP Addresses tab and for me,
changing IPAll to TCP port 1433 and deleting the TCP Dynamic Ports
value worked.

Follow the other steps to make sure 1433 is listening (Use netstat -an
to make sure 0.0.0.0:1433 is LISTENING.), and that you can telnet to
the port from the client machine.

Finally, I second the suggestion to remove the \SQLEXPRESS from the
connection.

AND ----> That last line is important! It looks like to be Windows 10 specific; remove \SQLEXPRESS from your connection string. What was frusting was that SQL Management Studio connects just fine using either connection string (full or short), however Visual Studio only accepted the connection string without the \SQLEXPRESS.

夜巴黎 2024-11-24 03:39:55

服务器上的活动防火墙可能会导致此问题。您可以尝试(暂时)将其关闭,看看是否可以解决问题。

如果确实是由防火墙引起的,那么据称您应该可以通过添加 TCP 端口 1433 设置为允许的入站规则来解决它,但我个人还无法通过这种方式连接。

The active firewall on the server might be causing this. You can try to (temporarily) turn it off and see if it resolves the issue.

If it is indeed caused by the firewall, you should allegedly be able to resolve it by adding an inbound rule for TCP port 1433 set to allowed, but I personally haven't been able to connect this way.

紫瑟鸿黎 2024-11-24 03:39:55

我遇到了同样的问题,但我通过在 SQL 配置管理器中重新启动浏览器服务并从连接窗口中的实例名称中删除 \SQLEXPRESS 解决了。

I had a Same Problem but i solved by Restarting the browser service in SQL CONFIGURATION MANAGER and removing \SQLEXPRESS from the instance name in the connection window.

一笔一画续写前缘 2024-11-24 03:39:55

这就是安全。确保您仔细检查了防火墙(Windows 和防病毒软件),在某些情况下,当您禁用防病毒防火墙并重新启动计算机时,Windows 防火墙会自动处于活动状态,并且仍然会阻止您的应用程序。希望这有帮助..

It's security all about. Make sure you have double check your firewall (windows and anti virus) in some cases when you disabled av firewall and restart your computer, automatically windows firewall is active and it's still block your application. Hope this is helpful ..

纵山崖 2024-11-24 03:39:55

您能否发布您正在使用的给您带来麻烦的连接字符串?
您可能需要将端口号添加到Data Source 值中,因为省略它也会产生 SQL 错误 26。

例如:Data Source=ServerHostName\SQLServerInstanceName,1433

Could you post the connection string you're using that's giving you trouble?
You might need to add the port number to the Data Source value, as omitting it can also produce SQL Error 26.

E.g.: Data Source=ServerHostName\SQLServerInstanceName,1433

枉心 2024-11-24 03:39:55

如果您已经做了任何事情但仍然无法连接?!!
就我而言,我更改了连接部分拆分端口“,”而不是“:”

连接字符串中未指定相应的 TCP 端口或管道名称(例如 Srv1\SQL2008, 1433)。

If you have done anything but in spite of all couldn't connecting?!!
In my case i have changed connection part splitting port "," instead of this ":"

The corresponding TCP port or pipe name is not specified in the connection string (such as Srv1\SQL2008, 1433).

一世旳自豪 2024-11-24 03:39:55

在 IT 人员更改了 SQL Server 上的一些安全设置后,这个问题也让我困惑了几天。

我有一个用于 Web 应用程序和桌面应用程序的 EntityFramework。

在我更改 SQL Server 上的一些设置后,Web 应用程序恢复工作,但桌面仍然面临问题。但我对两个应用程序使用了相同的连接字符串,一个正在工作而另一个却没有,这是没有意义的。

然后我搜索了很多,直到发现有人说这里需要添加$ServerName\$DatabaseInstanceName,1433 后的端口号 1433

添加后,异常变成:

System.Data.SqlClient.SqlException:用户登录失败
'域名\名称-PC$'

然后我发现了这个 链接。它说添加 Trusted_Connection=False;

整个连接字符串应该是这样的:

data source=XXXXX\SQLSERVER,1433;initial catalog=XXXDB;user id=UserID;password=PWD;Trusted_Connection=False;MultipleActiveResultSets=True;

希望这个答案能够帮助人们摆脱通用异常:

错误:定位指定的服务器/实例时出现 26 错误

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
'domain\name-PC$'

Then I found this link. It says to add Trusted_Connection=False;.

The whole connection string should be like:

data source=XXXXX\SQLSERVER,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

在风中等你 2024-11-24 03:39:55

您是否在 SQL 配置管理器中禁用了 VIA 设置?如果没有,请先禁用它(如果启用了 VIA,则无法连接)并且必须启用 TCP。尝试一下,它应该可以正常工作。

仅针对特定实例名称进行更改。

干杯!

Have you Disabled the VIA setting in the SQL configuration manager? If not, do disable it first (if VIA is enabled, you cannot get connected) and yes TCP must be enabled. Give it a try and it should be working fine.

Make the changes only for that's particular instance name.

Cheers!

坠似风落 2024-11-24 03:39:55

我发现这个网址非常有用:
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/2cdcab2e-ea49-4fd5-b2b8-13824ab4619b/help-server-not-listening-on-1433

特别是,我的问题是我没有在 Sql Server 配置管理器 -> SQL Server 网络中启用 TCP/IP配置 -> SQLEXPRESS 协议。

打开它后,您必须转到“IP 地址”选项卡,对我来说,将 IPAll 更改为 TCP 端口 1433 并删除 TCP 动态端口值是有效的。

按照其他步骤确保 1433 正在侦听(使用 netstat -an 确保 0.0.0.0:1433 正在侦听。),并且您可以从客户端计算机 telnet 到该端口。

最后,我同意从连接中删除 \SQLEXPRESS 的建议。

编辑:我应该注意我正在使用 SQL Server 2014 Express。

I found this url to be very useful:
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/2cdcab2e-ea49-4fd5-b2b8-13824ab4619b/help-server-not-listening-on-1433

In particular, my problem was that I did not enable the TCP/IP in Sql Server Configuration Manager->SQL Server Network Configuration->Protocols for SQLEXPRESS.

Once you open it, you have to go to the IP Addresses tab and for me, changing IPAll to TCP port 1433 and deleting the TCP Dynamic Ports value worked.

Follow the other steps to make sure 1433 is listening (Use netstat -an to make sure 0.0.0.0:1433 is LISTENING.), and that you can telnet to the port from the client machine.

Finally, I second the suggestion to remove the \SQLEXPRESS from the connection.

EDIT: I should note I am using SQL Server 2014 Express.

沧桑㈠ 2024-11-24 03:39:55

这确实有效..我已经验证了很多站点并最终得到了答案

当master.mdf或mastlog.ldf损坏时可能会发生这种情况。为了解决这个问题,请转到以下路径

C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL ,在那里你会找到一个文件夹“Template Data”,复制 master.mdf 和 mastlog.ldf 并将其替换为

C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA 文件夹。

就是这样 。现在启动 MS SQL 服务就完成了。

This really Works .. i had verified lot of sites and finally got the answer

This may occurs when the master.mdf or the mastlog.ldf gets corrupt . In order to solve the issue goto the following path

C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL , there you will find a folder ” Template Data ” , copy the master.mdf and mastlog.ldf and replace it in

C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA folder .

Thats it . Now start the MS SQL service and you are done .

太阳哥哥 2024-11-24 03:39:55

虽然导致此错误的原因可能有很多,但就我而言,它非常简单,我有一段时间忽略了这一点。我使用服务器 IP 地址以及 Server 的实例名称 -

<add name="MyDBConnection" 
connectionString="Persist Security Info=False;User ID=sa;Password=xxx;Database=MyDB;Server=nn.nn.n.nn\SQLInstance01; Connection Timeout=180" providerName="System.Data.SqlClient"/>

正确 连接字符串将如下所示(请注意,此字符串没有 SQL Server 实例名称)

<add name="MyDBConnection" 
connectionString="Persist Security Info=False;User ID=sa;Password=xxx;Database=MyDB;Server=nn.nn.n.nn; Connection Timeout=180" providerName="System.Data.SqlClient"/>

HTH 。

While there can be many reasons for this error - In my case it was pretty simple which I overlooked for a while. I was using server IP address along with instance name for Server as -

<add name="MyDBConnection" 
connectionString="Persist Security Info=False;User ID=sa;Password=xxx;Database=MyDB;Server=nn.nn.n.nn\SQLInstance01; Connection Timeout=180" providerName="System.Data.SqlClient"/>

Correct connection string will look something like this (note this one doesn't have SQL Server instance name)

<add name="MyDBConnection" 
connectionString="Persist Security Info=False;User ID=sa;Password=xxx;Database=MyDB;Server=nn.nn.n.nn; Connection Timeout=180" providerName="System.Data.SqlClient"/>

HTH.

守不住的情 2024-11-24 03:39:55

就我而言,启用共享内存足以解决问题。

只需确保重新启动即可使更改生效。

我使用 Windows 身份验证而不是以管理员身份访问 SQL Server Management Studio。

SQL Server 代理和浏览器服务保持禁用状态。

共享内存协议
[SQL 代理和浏览器服务2

错误详细信息:

无法连接到 DESKTOP-*****\SQLEXPRESS。

建立与 SQL Server 的连接时发生与网络相关或特定于实例的错误。找不到服务器或无法访问服务器。验证实例名称是否正确以及 SQL Server 是否配置为允许远程连接。 (提供程序:SQL 网络接口,错误:26 - 定位指定的服务器/实例时出错)(框架 Microsoft SqlClient 数据提供程序)

如需帮助,请单击:https://docs.microsoft.com/sql/relational-databases/errors-events/mssqlserver--1-database-engine-error

错误号:-1
严重程度:20
状态:0

In my case, enabling Shared Memory was enough to fix the issue.

Just make sure to restart for the change to take effect.

I access SQL Server Management Studio using Windows Authentication, and not as an Admin.

SQL Server Agent and Browser services remain disabled.

Shared Memory Protocol
[SQL Agent and Browser services2

Error detail:

Cannot connect to DESKTOP-*****\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) (Framework Microsoft SqlClient Data Provider)

For help, click: https://docs.microsoft.com/sql/relational-databases/errors-events/mssqlserver--1-database-engine-error

Error Number: -1
Severity: 20
State: 0

留一抹残留的笑 2024-11-24 03:39:55

就我而言,我安装了 SQL Express 2012,并在重新启动 PC 后出现问题。我解决了:

我转到服务 -> SQL Server (SQLEXPRESS),我发现它已停止。我开始了,它说登录错误。
在属性中,选项卡登录,我将其更改为本地系统帐户,然后我就可以启动SQL服务了。

然后为了测试它,我转到 SQL Server Management Studio 并连接到 .\SQLEXPRESS 并且它有效!

In my case, I Installed SQL Express 2012 and the problem raise after I reboot my PC. I solved so:

I go to Services -> SQL Server (SQLEXPRESS) and I see that was stopped. I started and It's say an login error.
In properties, Tab Log On, I change it to Local System account , then I can start the SQL service.

Then to test it, I go to SQL Server Management Studio and I connect to .\SQLEXPRESS and it works!

睡美人的小仙女 2024-11-24 03:39:55

我遇到了类似的问题,通过转到“SQL Server 配置管理器”并确保“SQL Server 浏览器”配置为自动启动并启动来解决该问题。
这对我有用

I had a similar problem which was solved by going to the "SQL Server Configuration Manager" and making sure that the "SQL Server Browser" was configured to start automatically and was started.
it works for me

蓝咒 2024-11-24 03:39:55

我在 sql server 上遇到了类似的问题,我已经尝试了所有方法,但无法连接到数据库引擎&它显示错误:26。

  • 首先检查数据库引擎是否正在运行。通过进入
    配置管理器。开始> sql服务器>sql服务器配置
    经理。在右侧窗格中,您应该看到 sql server (mss ..)
    应处于运行状态并带有绿色指示。
  • 如果数据库引擎没有运行,只需卸载sql
    服务器/如果可能的话格式化您的系统然后下载sql
    Server 2012 和管理工作室。来自
    https://www.microsoft.com/en-ca/download /details.aspx?id=29062

  • 先安装服务器,确保在安装阶段添加服务器
    单击“添加服务器”,然后安装 Management Studio。

I got a similar problem with sql server , I have tried every thing but does not connect to database engine & it shows error:26.

  • First check if the database engine is running or not. by going into
    configuration manager. start > sql server >sql server configuration
    manager. On the right pane you should see the sql server (mss .. )
    should be running state with a green indication.
  • IF the database engine is not running, simply uninstall sql
    server / format your system if possible and then download sql
    server 2012 and management studio. from
    https://www.microsoft.com/en-ca/download/details.aspx?id=29062

  • Install server first, make sure to add server on installation phase
    by clicking add server and then install management studio.

菩提树下叶撕阳。 2024-11-24 03:39:55

您需要做的就是进入控制面板>计算机管理>服务
并手动启动 SQL Express 或 SQL Server。
这对我有用。

祝你好运。

All you need to do is to go to the control panel > Computer Management > Services
and manually start the SQL express or SQL server.
It worked for me.

Good luck.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文