question

69673825 avatar image
0 Votes"
69673825 asked 69673825 answered

node js and mysql localhots refused connection.

I am getting "localhost refused connection" error.
With same parameters I can open the connection in workbench ok.

 'use strict';
 var http = require('http');
 var port = process.env.PORT ||1137;
    
 http.createServer(function (req, res) {
     res.writeHead(200, { 'Content-Type': 'text/plain' });
     res.end('Hello World333333\n');
 }).listen(port);
    
    
 var mysql = require('mysql');
    
 var con = mysql.createConnection({
     host: "localhost",
     user: "root",
     password: "Nigel7557@"
 });


azure-database-mysql
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

69673825 avatar image
0 Votes"
69673825 answered

It was a problem with cors.
Fixed now, thanks for your help.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AnuragSharma-MSFT avatar image
0 Votes"
AnuragSharma-MSFT answered

Hi @69673825, welcome to Microsoft Q&A forum.

Could you please try changing the localhost to '127.0.0.1', also check if the port you are connecting to in workbench is correct i.e. 3306?

Just one last thing, are you using the MySQL on-premise or Azure MySQL.?

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.