Error in insertion:connect ECONNREFUSED

I'm trying to insert a value into my database, which is mydb and the table is login with 2 fields username and password. I'm using express.js and MySQL. The code of insert query is

exports.insert = function(req,res){
    client.query('insert into' +TABLE+ ' SET username=?,password=?' 
                , [req.body.txtUser,req.body.txtPassword]
                ,          
                  function(err,result){  
                     if(err){
                             console.log("error in insertion:"+ err.message);   
                             }
                     else{
                          console.log("query executed");
                          res.json("data inserted");
                          }
                      } 
                 );
             }

When I start the server it starts normal;y and show me the message:

The Express server listening on port 3000 in development mode

But, when I visit the signup page and insert the value and press submit the following error is generated

error in insertion:connect ECONNREFUSED

Can anyone help me out?

This is not a Node.js issue. You're unable to connect to your MySQL client in general.

You need to give access and permissions within MySQL to the username you're using to connect. Give access and then try to login manually to test this connection using a MySQL client or admin tool such as MySQL Admin or the command line mysql client. Remember, that in MySQL you have to setup for localhost as well as remote. I believe it still defaults to localhost only. e.g. you will need to explicitly set admin@* for other hostnames. Read the MySQL Manual here

Once your client works, then your node.js client should work with the same username and settings.