简体   繁体   中英

ConnectionError [SequelizeConnectionError]: Failed to connect to :1433 - Could not connect (sequence) local machine window 10

***** mssql db connected sucessfully **** customers (node:116) [DEP0118] DeprecationWarning: The provided hostname "" is not a valid hostname, and is supported in the dns module solely for compatibility. (Use node --trace-deprecation... to show where the warning was created) ConnectionError [SequelizeConnectionError]: Failed to connect to:1433 - Could not connect (sequence) at ConnectionManager.connect (H:\codeoptimalsolutions\socialApp\backend\node_modules\sequelize\lib\dialects\mssql\connection-manager.js:139:17) at processTicksAndRejections (internal/process/task_queues.js:93:5) at async ConnectionManager._connect (H:\codeoptimalsolutions\socialApp\backend\node_modules\sequelize\lib\dialects\abstract\connection-manager.js:318:24) at async H:\codeoptimalsolutions\socialApp\backend\node_modules\sequelize\lib\dialects\abstract\connection-manager.js:250:32
at async ConnectionManager.getConnection (H:\codeoptimalsolutions\socialApp\backend\node_modules\sequelize\lib\dialects\abstract\connection-manager.js:280:7) at async H:\codeoptimalsolutions\socialApp\backend\node_modules\sequelize\lib\sequelize.js:613:26 at async MSSqlQueryInterface.select (H:\codeoptimalsolutions\socialApp\backend\node_modules\sequelize\lib\dialects\abstract\query-interface.js:953:12) at async Function.findAll (H:\codeoptimalsolutions\socialApp\backend\node_modules\sequelize\lib\model.js:1753:21) { parent: ConnectionError: Failed to connect to:1433 - Could not connect (sequence) at ConnectionError (H:\codeoptimalsolutions\socialApp\backend\node_modules\tedious\lib\errors.js:13:12) at Connection.socketError (H:\codeoptimalsolutions\socialApp\backend\node_modules\tedious\lib\connection.js:1641:56)
at H:\codeoptimalsolutions\socialApp\backend\node_modules\tedious\lib\connection.js:1400:21 at SequentialConnectionStrategy.connect (H:\codeoptimalsolutions\socialApp\backend\node_modules\tedious\lib\connector.js:129:14) at H:\codeoptimalsolutions\socialApp\backend\node_modules\tedious\lib\connector.js:201:80 at processTicksAndRejections (internal/process/task_queues.js:80:21) { code: 'ESOCKET' }, original: ConnectionError: Failed to connect to:1433 - Could not connect (sequence) at ConnectionError (H:\codeoptimalsolutions\socialApp\backend\node_modules\tedious\lib\errors.js:13:12) at Connection.socketError (H:\codeoptimalsolutions\socialApp\backend\node_modules\tedious\lib\connection.js:1641:56)
at H:\codeoptimalsolutions\socialApp\backend\node_modules\tedious\lib\connection.js:1400:21 at SequentialConnectionStrategy.connect (H:\codeoptimalsolutions\socialApp\backend\node_modules\tedious\lib\connector.js:129:14) at H:\codeoptimalsolutions\socialApp\backend\node_modules\tedious\lib\connector.js:201:80 at processTicksAndRejections (internal/process/task_queues.js:80:21) { code: 'ESOCKET' } }

I tried

  1. TCP/IP is enabled

  2. checked some answers ntng found all give me advice to enable TCP/IP

    var sequelize = new Sequelize(DBNAME,USERNAME,PASSWORD,{ dialect: 'mssql', host: hostname, port: 1433, logging: false, dialectOptions: { requestTimeout: 30000, encrypt: true } })

When i try to run get query then got this error

        Models.Customer.findAll({}, {}, {}).then(data=>{   
                      console.log(data);
          }).catch(err => { //console.log("err",err);
                      console.log(err);
          });

Bit of a stab in the dark because I don't feel there's enough information but the error states DeprecationWarning: The provided hostname "" is not a valid hostname, and is supported in the dns module solely for compatibility. Followed by a number of connection errors.

Your sequelize config contains:

   host: hostname,
  

So it looks to me as though "hostname" is returning an empty string but is necessary for the connection to proceed.

Edit to be a little more useful:

The sequelize documentation indicates that it defaults to localhost if not set , but here (I suspect) you are setting host name to an empty string. Try setting hostname explicitly to the database host and see if it connects.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM