title: NodeJS - MySQL remote mysql connection timeout error
body: <p>We are using GoDaddy. We want to connect to remote mysql by mysqljs and nodejs. It works on local server but it doesn't work on live server. We are receiving always same error:</p>
  
  <ul>
  <li><p>Error: connect ETIMEDOUT</p></li>
  <li><p>Error connecting to Db</p></li>
  </ul>
  
  <p><strong>Here is my connection code:</strong></p>
  
  <pre><code>var con = mysql.createConnection({
  
  domain: "http://domain.com/",
  host: "domain.com",
  port: 3306,
  user: "username",
  password: "password",
  database: "databasename"
    });
  
   con.connect(function(err){
  
  console.log(err);
  
  if(err){
    console.log('Error connecting to Db');
    return;
  }
  console.log('Connection established');
    con.query("SELECT * FROM users WHERE username='"+user+"' and password='"+pass+"' ", function(err, rows) {
  
      if (err) throw err;
  
       if (rows=='') {
  
         alert('Wrong username or password');
       }else {
  
         $.each(rows , function(key,value){
  
         if (value.username==user &amp;&amp; value.password==pass) {
  
          //window.location =('Home.html');
          window.location =('cpanel.html');
           }
          });
        }
  
  });
  });
  </code></pre>