0

I am relatively new to the Node JS, and I have been trying to connect to a remote mysql server, but I have been unable to do so. I have been looking for the solutions on here but most of them are for localhost. Here is my code:

var mysql = require('mysql');
var con = mysql.createConnection({
  host: "###.ipagemysql.com",
  user: "user",
  password: "mypass",
  database: "mydb",
  debug: true
});

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

});

I am getting the error below:

Error: connect ECONNREFUSED 103.224.212.250:3306
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1117:14)

UPDATE: I tried using a different MySQL server and that works fine. Could it be because iPage is blocking the connection because it is coming from a foreign machine? Is this something that can be configured in phpmyadmin?

1
  • have you checked the server connectivity on that port from your machine. try "telnet" to check if the connection is available. Commented Mar 18, 2019 at 7:34

1 Answer 1

1

Possibly port 3306 is not accessible from the application. You can try telnet to server 103.224.212.250:3306 to see if it is opened or not.

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

2 Comments

It appears it is in fact closed. I tried using a different mysql server and that works fine. Could it be because iPage is blocking the connection because it is coming from a foreign machine? Is this something that can be configured in phpmyadmin?
Since you has not give more details on how you currently connect to you db server. There are 2 possibility: user config and server config. For user config, it may be declared as 'user'@'localhost', so that user is only accessible if it is in the same host with mysql server. Server config is if mysql server open port 3306 for accessing from outside, i.e firewall

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.