Search code examples
mysqlnode.jsovh

MySQL Connection on Node.JS


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


Solution

  • 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.