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!
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:
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
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.