1

I have a problem when I try to connect to a MySQL database hosted by OVH on NodeJS server. Here is the code :

var mysql      = require('mysql');

var connection = mysql.createConnection({
  host     : 'my_ip',
  port     : '3306',
  user     : 'my_user',
  password : 'my_pass',
  connectTimeout : 10000
});

connection.connect(function(err) {
  if (err) {
    console.error('error connecting: ' + err.stack);
    return;
  }
  console.log('connected');
});

But I get :

error connecting: Error: connect ETIMEDOUT

Everytime, not matter what I do, like changing the timeout, remove the port or anything else. Any idea ? I'm running this on ArchLinux x86_64

2
  • What kind of hosting service is the database on? I'm asking because usually they don't allow remote connections to the database. Is the node server on the same machine or on a different one? Commented Oct 26, 2016 at 9:35
  • It's hosted on OVH and there's no problem to access it via PHP Commented Oct 26, 2016 at 9:47

2 Answers 2

2

I finally found the answer : OVH doesn't allow customers to use their MySQL Database out of their services which means that if you want to run code using MySQL OVH database, you have to run the code into a OVH server.

Sign up to request clarification or add additional context in comments.

Comments

0

This looks like a timeout error. Please try taking the port number out of the quote marks. Hopefully this will fix the issue!

 var connection = mysql.createConnection({
     host     : 'my_ip',
     port     : 3306,
     user     : 'my_user',
     password : 'my_pass',
     connectTimeout : 10000
});

4 Comments

Unfortunatly, it didn't change anything
Okay and can you connect to the remotely database using the same credentials in MySQLWorkbench for example?
It doesn't work, something might be wrong in the IP then ... Thanks for the help !
Yes, could be many things, is the database allowing remote connections or is it locked down? And are the credentials correct?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.