Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use host with backslash or path #10451

Open
ryanfabela opened this issue Feb 15, 2019 · 1 comment
Open

Cannot use host with backslash or path #10451

ryanfabela opened this issue Feb 15, 2019 · 1 comment

Comments

@ryanfabela
Copy link

What are you doing?

I am trying to use a host with a backslash

function configureInstance(databaseName) {
  const { DIALECT, OPERATORS_ALIASES, PORT, POOL } = DB_CONNECTION_SETTINGS;

  const sequelizeInstance = new Sequelize(
    databaseName,
    process.env.DB_USERNAME,
    process.env.DB_PASSWORD,
    {
      host: 'HOST_NAME\\PATH',
      dialect: DIALECT,
      operatorsAliases: OPERATORS_ALIASES,
      port: PORT,
      pool: POOL,
    }
  );

*HOST_NAME and PATH fillers for actual host

What do you expect to happen?

I expect to get 1 backslash in host used in Sequelize to properly connect

What is actually happening?

, instead I get connection error due to 2 being used. If I use only 1 backslash in config, I get 0 backslashes in host and another connection error

Dialect: mssql
Sequelize version: 4.38.1
Tested with latest release: No

@pranayusg
Copy link

pranayusg commented Aug 10, 2020

For sequelize users to connect from nodejs to mssql with hostname containing instanceName.
Backslash wont work for hostnames due to some rules of sequelize(tedious)
Try giving instanceName as shown
Worked for me
Ex: Host="192.168.4.64\SERVER1"

const Sequelize = require('sequelize');
const sequelize = new Sequelize('Audit', 'aaaa', 'bbbb', {
host: "192.168.4.64",
dialect: 'mssql',
dialectOptions: {
    options: {
      instanceName: 'SERVER1'
    }
  }
});

sequelize
.authenticate()
.then(() => {
console.log('Connection has been established successfully.');
})
.catch(err => {
console.error('Unable to connect to the database:', err);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants