DataBase Connection Custom

Hello, I want to create a custom database that can save my users. But when im try to do that i get that Failed to connect to localhost,1434:1433 - getaddrinfo ENOTFOUND localhost,1434 localhost,1434:1433"…

function login(email, password, callback) {
//this example uses the “tedious” library
//more info here:
const bcrypt = require(‘bcrypt’);
const sqlserver = require(‘tedious@1.11.0’);

const Connection = sqlserver.Connection;
const Request = sqlserver.Request;
const TYPES = sqlserver.TYPES;

const connection = new Connection({
userName: ‘-Have right it here------’,
password: ‘Have right it here-------’,
server: ‘localhost,1434’,
options: {
database: ‘Have right it here------’

const query = ‘SELECT Id, Nickname, Email, Password FROM dbo.Users WHERE Email = @Email’;

connection.on(‘debug’, function (text) {
}).on(‘errorMessage’, function (text) {
console.log(JSON.stringify(text, null, 2));
}).on(‘infoMessage’, function (text) {
console.log(JSON.stringify(text, null, 2));

connection.on(‘connect’, function (err) {
if (err) return callback(err);

const request = new Request(query, function (err, rowCount, rows) {
  if (err || rowCount < 1) return callback(err || new WrongUsernameOrPasswordError(email));, rows[0][3].value, function (err, isValid) {
    if (err || !isValid) return callback(err || new WrongUsernameOrPasswordError(email));

    callback(null, {
      user_id: rows[0][0].value,
      nickname: rows[0][1].value,
      email: rows[0][2].value

request.addParameter('Email', TYPES.VarChar, email);


localhost means the host the script is running on, in this case an Auth0 server.

You need to run your DB on a publicly available IP address.


1 Like

Thanks for sharing that solution John!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.