1

I'm having a weird issue trying to connect my Node.js app (hosted on Heroku) to my ClearDB database. If I'm hosting my server on localhost I can connect to the remote DB no problem.

Initially I was using mysql.createConnection(process.env.CLEARDB_DATABASE_URL) and everything worked fine. The problem is that CloudDB will close the connection after 90 seconds which then crashed my Node app.

My solution was to use mysql.createPool, but when I do this I get Access denied for user 'xxxxxxxxx'@'ip-10-0-113-69.ec2.internal.

I couldn't find a way to use CLEARDB_DATABASE_URL with createPool, so I had to break the url down myself, but I don't understand where this is causing issues. To my understanding, the mysql url sting is broken down like mysql://[username]:[password]@[hostname]/[databasename] and this is how I supplied it to my program.

This is the code I'm using for pool:

let pool = mysql.createPool({
    connectionLimit: 100,
    host: process.env.HOST,
    user: process.env.USER,
    password: process.env.PWD,
    database: process.env.DB
});

Any clues that might point to the right direction are helpful.

Jeffrey Carr
  • 137
  • 9

0 Answers0