I am using the server side of Node.js. I tried my code on localhost and everything works fine. I bought a server and installed Apache and Node.js on it and checked my web application there. I correctly changed the MySQL connection configurations from localhost to server configurations.
I am testing my web application using this configuration:
var mysql = require('mysql'); var mysqlConnection; function new_mysqlConnection() { mysqlConnection = mysql.createConnection({ host : 'myurl.at', user : 'myusername', database : 'mydatabase', password : 'mypassword' }); }
I start the Node.js server using
$ node server.js
When I load the page, it displays correctly, but when Node.js tries to connect to the database, I always get the following error:
Error: connect ECONNREFUSED at errnoException (net.js:905:11) at Object.afterConnect [as oncomplete] (net.js:896:19) -------------------- at Protocol._enqueue (/var/www/node_modules/mysql/lib/protocol/Protocol.js:135:48) at Protocol.handshake (/var/www/node_modules/mysql/lib/protocol/Protocol.js:52:41) at Connection.connect (/var/www/node_modules/mysql/lib/Connection.js:119:18) at reconnectDb (/var/www/server.js:319:18) at app.get.email (/var/www/server.js:109:2) at Layer.handle [as handle_request] (/var/www/node_modules/express/lib/router/layer.js:82:5) at trim_prefix (/var/www/node_modules/express/lib/router/index.js:302:13) at /var/www/node_modules/express/lib/router/index.js:270:7 at Function.proto.process_params (/var/www/node_modules/express/lib/router/index.js:321:12) at next (/var/www/node_modules/express/lib/router/index.js:261:10)
Nico source share