Node.js MySQL database connection - time out (ETIMEDOUT)

Viewed 7062

I try to make a simple connection to an online mysql database on a node.js server. This is my code:

var mysql = require('mysql');

var con = mysql.createConnection({
    host: 'example.org',
    username: 'myusername',
    password: 'mypassword'
});

con.connect(function(err) {
    if (err) throw err;
    console.log("Connected!");
});

Whenever I run this server I get the error: "connect ETIMEDOUT".

I am a 100% sure my credentials are correct and I also changed the privileges of the user in phpmyadmin (I gave this user all possible privileges).

I run the server locally, I am not sure if this has anything to do with it.

My questions are: - Why is it timing out? - And how can I connect to this database?

1 Answers
Related