Auth0 and local database ran in a docker container

Hey there!

I’ve got a web-page at localhost:8080 with a login button that triggers a call to the auth0 handler. It works fine as long as it interacts with their database. Now i’m trying to set-up my own database, but can’t seem to fill correctly the login script.

My database runs through a docker container via the command-line:

docker run —ip=“” —net=“unihub-network” -p 13306:3306 -e MYSQL_ROOT_PASSWORD=mypasswd -d unihub-mysql

Using their template, I wrote:

function login(email, password, callback) {
var connection = mysql({
host: ‘my-ip-address’, //my current ip address
user: ‘my-user’, //username and password used to access the DB via SQuirreL
password: ‘my-psw’,
database: ‘UNIHUB_DB’ //supposed to be the name of my db

Which obviously doesn’t work. I can access my DB through software like SQuirreL at jdbc:mysql://localhost:13306/UNIHUB_DB, but it looks like i would need to access it through a URL to put in the login script for auth0.

Any thought on this ?

As you noted, the database is running locally (in your machine/container) and if you want to use it as part of a custom database connection (Custom Database Connections) then that database needs to be accessible over the public network (Internet). In other words, you can’t use localhost, but it should be possible to use your public IP address as long as the inbound connection to the respective port is allowed.

I believe it should also be possible to use services like to expose that local database in order to perform quick tests while in development. However, down the line you’ll have to have a production database that is publicly hosted in something other than your personal machine so you may even want to consider if it’s not just simpler to also host a version of the database for development at the same hosting service because that would also simplify scenarios where multiple developers exist.