DEV Community

ADEKOLA Abdwahab
ADEKOLA Abdwahab

Posted on

SMTP NODEMAILER TOO MANY CONNECTIONS

Straight to the point, if you encounter this error while sending emails via nodemailer module then you are likely sending too many mails while creating/using different connections simultaneously.

nodemailer error message

SOLUTION -

Configure your transporter to use the pool feature. See how below.

nodemailer pooling config

You should be fine by now, so let's go verbose.

When you make a request to a server, a connection is opened to that server. If you do not have other requests at that time, then you may forget abou the opened connection and go your way.

If you have another request, say instantly, you may also open another connection to that server. Meaning, you can open a different connection for each request that you want to make. Hence, from your authentication, you can have multiple connections opened at the same time - simultaneously.

It is possible you attempt that, and it is possible that the server limit how much you can open - the limit.

The question is, why can't we reuse a connection that we have already opened? To save resources. The art of reusing opened connections is POOLING.

Hence, instead of opening multiple, unnecessary, connections we can just open one, or a few, and reuse them as required.

Fortunately, nodemail supports this.

Top comments (0)