简体   繁体   English

ConnectionError:无法连接到localhost:15000ms内未定义

[英]ConnectionError: Failed to connect to localhost:undefined in 15000ms

I am using KnexJs attempting to connect to a local Microsoft SQL Server Express. 我正在使用KnexJs尝试连接到本地Microsoft SQL Server Express。 However, with the below configuration, I am getting an error. 但是,使用以下配置,我收到一个错误。 I've followed the typical steps, but I'm still getting the error. 我遵循了典型的步骤,但我仍然得到错误。

What I've tried: 我尝试过的:

  1. Set up a SQL Server authentication login for the database 为数据库设置SQL Server身份验证登录
  2. Enable SQL Server authentication on the server 在服务器上启用SQL Server身份验证
  3. Enable TCP/IP on the server 在服务器上启用TCP / IP
  4. Restart the Windows services 重新启动Windows服务
  5. Restart the SQL Server through SQL Server Management Studio 通过SQL Server Management Studio重新启动SQL Server
  6. Verify ability to log in through SQL Server Management Studio 验证通过SQL Server Management Studio登录的能力

Configuration / query code: 配置/查询代码:

    let mssql = knex({
        client: 'mssql',
        connection: {
          host: 'localhost\\sqlexpress',
          user: 'test',
          password: 'test',
          database: 'AdventureWorks2017',
          // port:1433,
          // options: {
          //   trustedConnection: true
          // },
          useNullAsDefault: true
        }
      });

    mssql.raw('select 1 as result').then(function (result) {
      console.log('result');
      console.log(result);
      mainWindow.webContents.send('testConnectionResponse', result === 1);
      event.sender.send('testConnectionResponse', result === 1);
    }).catch(function (err) {
      console.log(err);
      mainWindow.webContents.send('query-error', err);
    }).finally(() => {
      mssql.destroy();
    });

Error: 错误:

ConnectionError: Failed to connect to localhost:undefined in 15000ms ConnectionError:无法连接到localhost:15000ms内未定义

It turns out that I also needed to enable the SQL Server Browser windows service like so: 事实证明,我还需要启用SQL Server Browser Windows服务,如下所示:

  1. Navigate to "Services" 导航到“服务”
  2. Select "Properties" on "SQL Server Browser" 在“SQL Server Browser”上选择“属性”
  3. Flip "Start up type" to "Automatic" 将“启动类型”翻转为“自动”
  4. Start the service 启动服务

Success! 成功!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 [连接错误:15000 毫秒内无法连接到 IP] - [ConnectionError: Failed to connect to IP in 15000ms] 如何解决“ConnectionError:无法连接到<server> :<port> 在 15000 毫秒内”错误? - How do I fix the "ConnectionError: failed to connect to <server>:<port> in 15000ms" error? 无法在 15000 毫秒内连接到 mydb.database.windows.net:1433(Microsoft Azure SQL 数据库) - Failed to connect to mydb.database.windows.net:1433 in 15000ms (Microsoft Azure SQL Database) 天蓝色的移动服务调用sql服务器存储过程并获得requestTimeout 15000ms错误 - azure mobile services calling sql server stored procedure and get a requestTimeout 15000ms error 使用 sequelize-automate 出现错误“ConnectionError [SequelizeConnectionError]:无法连接到 localhost:1443 - 无法连接(序列)” - Error "ConnectionError [SequelizeConnectionError]: Failed to connect to localhost:1443 - Could not connect (sequence)" using sequelize-automate Node.js MSSQL tedius ConnectionError: Failed to connect to localhost:1433 - connect ECONNREFUSED - Node.js MSSQL tedius ConnectionError: Failed to connect to localhost:1433 - connect ECONNREFUSED ConnectionError:无法连接到MyServer:1433 - ConnectionError: Failed to connect to MyServer:1433 ConnectionError:无法连接到 <SQLServerDB> -连接EACCES <SQLServerDB> - ConnectionError: Failed to connect to <SQLServerDB> - connect EACCES <SQLServerDB> ConnectionError:无法连接到{数据库服务器}-无法连接(顺序) - ConnectionError: Failed to connect to {database server} - Could not connect (sequence) ConnectionError [SequelizeConnectionError]:无法连接到:1433 - 无法连接(序列)本地机器 window 10 - ConnectionError [SequelizeConnectionError]: Failed to connect to :1433 - Could not connect (sequence) local machine window 10
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM