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.

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay