title: nodeMailer error nodejs: Error: connect ECONNREFUSED 127.0.0.1:587
body: <p>I writed this code in node.js - visual studio code,
  the database is mongoDB atlas
  (the code sends mail with token details after login):</p>
  <pre><code>function sendMail(email, name, tkn) {
      let transporter = nodemailer.createTransport({
          service: 'workers',
          auth: {
              user: process.env.EMAIL_ADDRESS,
              pass: process.env.EMAIL_PASSWORD
          }
      });
  
      let mailOptions = {
          from: process.env.MAIL,
          to: email,
          subject: `welcome ${name}`,
          text: `your token is ${tkn} `
      };
  transporter.sendMail(mailOptions, function (err, info) {
      if (err) {
          console.log(err);
      } else {
          console.log('email sent:' + info.response);
      }
  });
  }
  
  const checkPermission = async (req, res) =&gt; {
      try {
          /*let employed = */await Employed.findOne({
              email: req.body.email,
              password: req.body.password
          }).then((employed) =&gt; {
                  const token = jwt.sign({ id: employed._id }, process.env.ACCESS_TOKEN_SECRET)
                  sendMail(employed.email, employed.full_name, token);
                  res.status(200).send(`successfull login ${employed}`)
              })
      } catch (err) {
          res.status(400).send(`error: ${err.message}`);
      }
  }
  </code></pre>
  <p>this is the postman:</p>
  <pre><code>localhost:4000/checkPermission
  </code></pre>
  <p>it runs but the mail is not sended and i get this error in the terminal:</p>
  <pre><code>Error: connect ECONNREFUSED 127.0.0.1:587
      at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
    errno: -4078,
    code: 'ESOCKET',
    syscall: 'connect',
    address: '127.0.0.1',
    port: 587,
    command: 'CONN'
  }
  </code></pre>
  <p>do you know what the problem is? thanks ahead!</p>