Nodemailer with Dreamhost error: connection timed out

I am trying to configure Nodemailer with Dreamhost SMTP and having an error that I can’t figure out. I’ve tried different ports with no luck. Here is my setup code:

'use strict';
 const nodemailer = require('nodemailer');

   // create reusable transporter object using the default SMTP transport
   var transporter = nodemailer.createTransport({
    host: '',
    port: 587,
    secure: false, // true for 465, false for other ports
    auth: {
        user: '',
        pass: 'mypassword'

// setup email data with unicode symbols
var mailOptions = {
    from: '', // sender address
    to: '', // list of receivers
    subject: 'Hello ✔', // Subject line
    text: 'Hello world?', // plain text body
    html: '<b>Hello world?</b>' // html body

// send mail with defined transport object
transporter.sendMail(mailOptions, (error, info) => {
    if (error) {
        return console.log(error);
    console.log('Message sent: %s', info.messageId);


and the error:

{ Error: Connection timeout
at SMTPConnection._formatError (/home/ubuntu/workspace/node_modules/nodemailer/lib/smtp-connection/index.js:591:19)
at SMTPConnection._onError (/home/ubuntu/workspace/node_modules/nodemailer/lib/smtp-connection/index.js:564:20)
at Timeout._connectionTimeout.setTimeout (/home/ubuntu/workspace/node_modules/nodemailer/lib/smtp-connection/index.js:256:18)
at ontimeout (timers.js:386:14)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5) code: 'ETIMEDOUT', command: 'CONN' }

The port looks correct but the secure set to false looks weird to me: it should be true. Have you to connect with an email client like Thunderbird with that configuration?

You may want to experiment with other options to try and force TLS, too. Let us know how that goes.

I looked at your post because I was doing the same thing, and doing the following worked:

var email =;
var fromEmail = encodeURIComponent('');
const fromPassword = encodeURIComponent('mypassword');
var APP_NAME = 'My App';
var mailOptions = {
    from: `${APP_NAME} <>`,
    to: email
var transporter = nodemailer.createTransport({
    host: '',
    port: 587,
    secure: false, // true for 465, false for other ports
    requireTLS: true, //Force TLS
    tls: {  
        rejectUnauthorized: false
    auth: {
        user: ',
        pass: 'mypassword'

mailOptions.subject = `Charge failed for ${APP_NAME}!`;
mailOptions.text = `Your charge for next month of usage for ${APP_NAME} failed. Please open the app and update your payment information.\n\nSincerely,\n${APP_NAME}`;
transporter.sendMail(mailOptions).then(() => {
    console.log('Charge failed email sent to:', email);
1 Like

Did you have to do anything inside Dreamhost to configure? I’m using your solution and I’m getting the same error.

The configuration I have is this:

Email Client Configuration

To check your email go to webmail, then enter the first part of your email address, before the @, and your password to sign in.
If you need help setting up your email address in your email client, please see the following article on the DreamHost Wiki: Email Client Configuration.

Incoming mail server: mail.<DOMAIN>.com 
Incoming mail server type: POP3 or IMAP (your choice) 
Incoming mail server username: support@<DOMAIN>.com (use the whole thing!)

Outgoing (SMTP) mail server: mail.<DOMAIN>.com
My server requires authentication: checked. (use same settings as incoming mail server) 
Use secure password authentication: not checked.

I did not touch ports. I’m sending emails from Google Firebase.

Make sure you’re using the right SMTP server name for your account. Found out which one by reading the docs. If you’re using the right server, share more details about your setup please.

Well as is typical the solution was simple and a bit stupid. I’m still using the same setup as yaizudamashii, only for host I used the sub5 dreamhost server rather than my For those reading in the future, the problem was I was using Cloud9 as my development environment. I believe C9 has some kind of firewall in place which was blocking the 587 port. When I deployed the application it worked.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.