【问题标题】:ConnectionError: Failed to connect to <SQLServerDB> - connect EACCES <SQLServerDB>ConnectionError: 无法连接到 <SQLServerDB> - 连接 EACCES <SQLServerDB>
【发布时间】:2018-11-27 00:01:24
【问题描述】:

我正在尝试使用 Azure Cloud 中的配置连接到 SQL 服务器数据库:

       var config = {
              user: UserName,
              password: Password,
              server: Server IP,
              dialect:'mssql',
              options: {database: DBName}
          };
    sql.connect(config, function (err) {
//Code
}

代码在 node.js 中,在我的远程桌面上运行良好。但是在我将它托管在 Azure Cloud 中之后,我一直遇到这个错误

ConnectionError: 无法连接到 {SQLServerDB} - 连接 EACCES {SQLServerDB} 在 Connection.tedious.once.err (D:\home\site\wwwroot\node_modules\mssql\lib\tedious.js:216:17) 在 Connection.g (events.js:291:16) 在 emitOne (events.js:96:13) 在 Connection.emit (events.js:188:7) 在 Connection.socketError (D:\home\site\wwwroot\node_modules\tedious\lib\connection.js:1004:14) 在 D:\home\site\wwwroot\node_modules\tedious\lib\connection.js:869:25 在 Socket.onError (D:\home\site\wwwroot\node_modules\tedious\lib\connector.js:49:9) 在 emitOne (events.js:96:13) 在 Socket.emit (events.js:188:7) 在 emitErrorNT (net.js:1276:8) 代码:'ESOCKET',originalError:{ ConnectionError:无法连接到 {SQLServerDB} - 在 ConnectionError (D:\home\site\wwwroot\node_modules\tedious\lib\errors.js:12:12) 处连接 EACCES {SQLServerDB} 在 Connection.socketError (D:\home\site\wwwroot\node_modules\tedious\lib\connection.js:1004:30) 在 D:\home\site\wwwroot\node_modules\tedious\lib\connection.js:869:25 在 Socket.onError (D:\home\site\wwwroot\node_modules\tedious\lib\connector.js:49:9) 在 emitOne (events.js:96:13) 在 Socket.emit (events.js:188:7) 在 emitErrorNT (net.js:1276:8) 在 _combinedTickCallback (内部/进程/next_tick.js:74:11) 在 process._tickDomainCallback (internal/process/next_tick.js:122:9) 消息:'无法连接到 {SQLServerDB} - 连接 EACCES {SQLServerDB}, 代码:'ESOCKET' },名称:'ConnectionError' }

SQL Server 正在使用默认端口并且 TCP/IP 已启用。

【问题讨论】:

    标签: sql-server node.js azure


    【解决方案1】:

    根据错误信息,它表示它无法连接到您的 SQL 服务器。 我假设您使用的是本地 SQL 服务器。

    如果是这种情况,webapp默认无法连接本地SQL服务器。您可以使用Hybrid connections 来确保您可以连接到本地 SQL 服务器。我还建议您可以使用Azure SQL database 替换本地SQL 服务器。

    【讨论】:

    • 谢谢@Tom Sun
    • 我正在使用位于 azure 上的数据库,并且节点应用程序也位于同一台服务器上。仍然遇到与上面提到的@JeminJose 相同的错误。我是天蓝色的新手。请帮忙。
    猜你喜欢
    • 2019-12-07
    • 1970-01-01
    • 2018-08-17
    • 2020-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-14
    • 1970-01-01
    相关资源
    最近更新 更多