Report this

What is the reason for this report?

Nodemailer stopped working after migrating from shared hosting to a DigitalOcean Droplet

Posted on May 19, 2026

I recently moved my Node.js app from shared hosting to a DigitalOcean Droplet. On shared hosting, sending emails via Nodemailer with SMTP worked perfectly. Since moving to the Droplet, emails are not going out at all. I am getting connection timeout errors on port 25 and port 465.

My code has not changed, the SMTP credentials are the same, and I double checked the firewall rules. Everything looks correct but emails just will not send.

Has anyone run into this after migrating to a Droplet? What is the fix?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there,

This is a very common thing, DigitalOcean blocks outbound port 25 by default on all new accounts to prevent spam abuse. Port 465 can also be affected depending on your setup. This is a platform-level restriction, not a firewall misconfiguration on your end.

On shared hosting, your provider was likely running their own mail infrastructure or had already negotiated an SMTP relationship on your behalf, which is why it worked there without any extra setup.

The fix is to stop sending directly via SMTP from the Droplet and use a dedicated transactional email service instead. They handle IP reputation, bounce management, and deliverability for you, and they support port 587 which is not blocked.

A few worth considering:

  • smtpfa.st is built specifically for fast, reliable transactional SMTP and plugs into Nodemailer with minimal config changes.
  • Postmark is excellent for deliverability and is strict about what goes through their platform, which works in your favour long term.
  • Mailgun is a solid middle ground with a reasonable free tier to get started.

Swapping in any of these is a small change in your Nodemailer config:

const transporter = nodemailer.createTransport({
  host: 'your-smtp-provider-host',
  port: 587,
  secure: false,
  auth: {
    user: 'your-username',
    pass: 'your-password',
  },
});

More context on why DigitalOcean blocks SMTP here: https://docs.digitalocean.com/support/why-is-smtp-blocked/

Heya, @e13d124f55014cf1a5bfd586997890

DigitalOcean blocks outbound port 25 by default on all new Droplets. If your SMTP config is using port 25 it is going to fail.

You can use a dedicated mail provider like smtpfast, mailgun, sendgrid and to send your emails.

Regards

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

Dark mode is coming soon.