Auth0 Home Blog Docs

Auth0 login to SQL server database failed

sql-server
auth0
javascript

#1

I want to connect to my SQL SERVER database using this javascript code (code in https://manage.auth0.com on cloud):

function login(email, password, callback) {
    var connection = sqlserver.connect({
    userName: 'username',
    password: 'mypassword',
    server: 'TUN040474\\dblocal',
    options: {
       database: 'myDB',
       rowCollectionOnRequestCompletion: true
            }
});

I obtained this error: connection to TUN040474\dblocal:1433 - failed Error: getaddrinfo ENOTFOUND TUN040474\dblocal TUN040474\dblocal:1433

After googling (Custom database - defining the server) I understood that I have to do theese two steps:

  • configure my FireWall by adding rule for port 1433 for any IP Address
  • in my function replace server ‘TUN040474\dblocal’ by the Ip Address of my host because the code is in the cloud.

So I did them. But it still not working and i obtained this error:

“timeout : failed to connect to 41.224.17.185:1433 in 15000ms”

i have tried all ip addresses in ipconfig

this is the new code

function login(email, password, callback) {
var connection = sqlserver.connect({
userName: 'username',
password: 'mypassword',
server: '41.224.17.185', // I tried all ip addresses in ipconfig
options: {
   database: 'myDB',
   rowCollectionOnRequestCompletion: true
        }

});

Is there anyone who has had this problem and solved it?