# Nodemailer: Error: connect ETIMEDOUT 142.250.27.108:465 (code: 'ETIMEDOUT', command: 'CONN')

**Code:** `Nodemailer: ETIMEDOUT / ECONNECTION` · **Category:** Email / SMTP · **Seen on:** SMTP, Node.js, Linux

Nodemailer could not open a connection to the SMTP server before the timeout — a blocked port, wrong host, or network issue.

## 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

1. Test with `nc -vz smtp.example.com 587`
2. Try 587 STARTTLS or 2525 (many ESPs accept it)
3. Use the provider's HTTP API if SMTP is blocked

## Detailed fix by platform

### Linux

1. `nc -vz smtp.gmail.com 587` and `nc -vz smtp.gmail.com 465`

## Code examples

### Explicit ports and timeouts

```javascript
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

1. **Port** — Reachable with nc?
2. **Host** — Correct?
3. **Cloud** — Outbound SMTP restricted?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/email/nodemailer-etimedout-econnection)
