Nodemailer: Error: connect ETIMEDOUT 142.250.27.108:465 (code: 'ETIMEDOUT', command: 'CONN')
Nodemailer could not open a connection to the SMTP server before the timeout — a blocked port, wrong host, or network issue.
Error: connect ETIMEDOUT (code: 'ETIMEDOUT', command: 'CONN')Nodemailer ETIMEDOUTError: connect ECONNREFUSED 127.0.0.1:587 nodemailercode: 'ECONNECTION'Connection timeout nodemailer Meaning
Cloud hosts and home ISPs often block outbound SMTP ports (25, sometimes 465/587). ETIMEDOUT means packets got no answer; ECONNREFUSED means a host answered but nothing is listening. Test with nc or telnet, try another port, or use an HTTP API-based ESP, which avoids SMTP ports.
Common causes
- Outbound SMTP ports blocked by cloud provider/ISP/firewall
- Wrong host or port
- IPv6 resolution to an unreachable address
- Corporate proxy
- Slow DNS
⚡ Quick fix
- Test with
nc -vz smtp.example.com 587 - Try 587 STARTTLS or 2525 (many ESPs accept it)
- Use the provider's HTTP API if SMTP is blocked
Detailed fix by platform
Linux
nc -vz smtp.gmail.com 587andnc -vz smtp.gmail.com 465
Code examples
Explicit ports and timeouts
const nodemailer = require("nodemailer");
const t = nodemailer.createTransport({
host: "smtp.example.com", port: 587, secure: false,
connectionTimeout: 15000, greetingTimeout: 15000,
auth: { user: process.env.SMTP_USER, pass: process.env.SMTP_PASS },
});How to diagnose
- Port — Reachable with nc?
- Host — Correct?
- Cloud — Outbound SMTP restricted?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- 421 4.7.0 Try again later (rate limited) SMTP: 421 4.7.0 Our system has detected an unusual rate of unsolicited mail originating from your IP address. Mail sent from your IP address has been temporarily rate limited
- 450 4.7.1 Greylisted, please try again later SMTP: 450 4.7.1 <user@example.com>: Recipient address rejected: Greylisted, see http://postgrey.schweikert.ch/help/example.com.html
- ConnectionRefusedError [Errno 111] (SMTP) Python: ConnectionRefusedError: [Errno 111] Connection refused — smtplib connect to localhost:25
Most viewed in Email / SMTP
Other ways to find it
Where this error sits
Origin: Network. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 4 Nov 2026