# Connect to local DB

**URL:** <https://community.auth0.com/t/connect-to-local-db/36937>\
**Category:** Get Help\
**Created:** [January 28, 2020, 10:47am UTC](https://community.auth0.com/t/connect-to-local-db/36937 "2020-01-28T10:47:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dummy.intco](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dummy.intco/32/17242_2.png) [@dummy.intco](https://community.auth0.com/u/dummy.intco)\
**Post date:** [January 28, 2020, 10:47am UTC](https://community.auth0.com/t/connect-to-local-db/36937/1 "2020-01-28T10:47:59Z")

</div>

Hello,  
With the help of own custom DB feature, I want to connect to my local systems DB.  
I am connecting local DB with auth0 by ngrok.

I have already created a connection, and used all the MySQL templates to connect with this DB.  
But while clicking on Try button. It is just loading and gives the following error.

`ERROR:-> "connect ETIMEDOUT".`

template connection script is below.

```auto
function login(email, password, callback) {
  const mysql = require('mysql');
  const bcrypt = require('bcrypt');

  const connection = mysql.createConnection({
    host: '738b7e42.ngrok.io', // this link is generated by ngrok
    user: 'root', //usernae
    password: '', //pass
    port: 3306, //port
    database: 'mycustomdb' //
  });

  connection.connect();
}

```

And also how can I use these scripts in laravel(front-end =reactjs)?  
one thing i want to without “createConnection” gives me this error.  
2)“[SandboxUnhandledError] MySQL is not a function”.  
if you want tenant name or any plz ask for it.  
I am beginner one n the auth0.

---

<div class="post-metadata">

**Author:** ![lucas.sonich](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lucas.sonich/32/17240_2.png) [@lucas.sonich](https://community.auth0.com/u/lucas.sonich)\
**Post date:** [January 28, 2020, 5:08pm UTC](https://community.auth0.com/t/connect-to-local-db/36937/2 "2020-01-28T17:08:56Z")

</div>

Hello! Welcome to our community.

This error could be high latency between Auth0, ngrok and the local machine. We recommend to use a database in an actual server.

Thanks.

---

<div class="post-metadata">

**Author:** ![dummy.intco](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dummy.intco/32/17242_2.png) [@dummy.intco](https://community.auth0.com/u/dummy.intco)\
**Post date:** [January 29, 2020, 11:00am UTC](https://community.auth0.com/t/connect-to-local-db/36937/3 "2020-01-29T11:00:12Z")

</div>

## Hi @lucas.sonich, i have tried with server but below msg is showing. { Error: ER\_ACCESS\_DENIED\_ERROR: Access denied for user ‘myuser’@‘[pus-a-uw2-2.outbound.auth0user.net](http://pus-a-uw2-2.outbound.auth0user.net)’ (using password: YES) at Handshake.Sequence.\_packetToError (/data/\_verquire/mysql/2.7.0/node\_modules/mysql/lib/protocol/sequences/Sequence.js:48:14) at Handshake.ErrorPacket (/data/\_verquire/mysql/2.7.0/node\_modules/mysql/lib/protocol/sequences/Handshake.js:101:18) at Protocol.\_parsePacket (/data/\_verquire/mysql/2.7.0/node\_modules/mysql/lib/protocol/Protocol.js:271:23) at Parser.write (/data/\_verquire/mysql/2.7.0/node\_modules/mysql/lib/protocol/Parser.js:77:12) at Protocol.write (/data/\_verquire/mysql/2.7.0/node\_modules/mysql/lib/protocol/Protocol.js:39:16) at Socket. (/data/\_verquire/mysql/2.7.0/node\_modules/mysql/lib/Connection.js:96:28) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (\_stream\_readable.js:263:12) at readableAddChunk (\_stream\_readable.js:250:11)

at Protocol.\_enqueue (/data/\_verquire/mysql/2.7.0/node\_modules/mysql/lib/protocol/Protocol.js:135:48)  
at Protocol.handshake (/data/\_verquire/mysql/2.7.0/node\_modules/mysql/lib/protocol/Protocol.js:52:41)  
at Connection.connect (/data/\_verquire/mysql/2.7.0/node\_modules/mysql/lib/Connection.js:123:18)  
at login (/data/io/20c5ba8a-90c9-4e48-af48-52d5d5d188dc/webtask.js:18:15)  
at /data/io/20c5ba8a-90c9-4e48-af48-52d5d5d188dc/webtask.js:44:2  
at Async.waterfall (/data/sandbox/lib/sandbox.js:617:33)  
at nextTask (/data/sandbox/node\_modules/async/dist/async.js:5324:14)  
at next (/data/sandbox/node\_modules/async/dist/async.js:5331:9)  
at /data/sandbox/node\_modules/async/dist/async.js:969:16  
at Async.waterfall (/data/sandbox/lib/sandbox.js:506:24)  
code: ‘ER\_ACCESS\_DENIED\_ERROR’,  
errno: 1045,  
sqlState: ‘28000’,  
fatal: true }

My code is:  
function login(email, password, callback) {  
const mysql = require(‘mysql’);  
const bcrypt = require(‘bcrypt’);

const connection = mysql.createConnection({  
port:3306,  
host: MY\_HOST,  
user: configuration.MY\_USER,  
password: configuration.MY\_PASS,  
database: configuration.MY\_DB  
});  
}  
plz reply ASAP.

---

<div class="post-metadata">

**Author:** ![lucas.sonich](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lucas.sonich/32/17240_2.png) [@lucas.sonich](https://community.auth0.com/u/lucas.sonich)\
**Post date:** [January 31, 2020, 5:09pm UTC](https://community.auth0.com/t/connect-to-local-db/36937/4 "2020-01-31T17:09:46Z")

</div>

Hello!

We noticed that the information in your code might be the template information (e.g. user ‘myuser’). You will need to provide your own information to your code to be able to connect to your server.

Thanks.
