Fix “SMTP connect() failed” / “Could not connect to SMTP host” in WP Mail SMTP

These errors mean WordPress couldn’t reach your SMTP server. The most common causes are a hosting firewall blocking ports 587/465, a wrong host/port/encryption combo (TLS vs SSL), or Cloudflare/DNS pointing SMTP to the wrong place. Below is a fast path, then bulletproof steps with logs to prove the exact cause.

WP Mail SMTP shows “SMTP connect() failed” / “Could not connect to SMTP host.” Can you give me the fastest fix and then the full, safe steps?

Updated November 2025

TL;DR: This is a connection failure (not authentication).

30‑Second Quick Fix

  1. Open Debug Events & retest: WP Mail SMTP → Tools → Debug Events → send a test → click the latest event to read the exact failure (timeout 110, refused 111, DNS). How to use Debug Events
  2. Set the correct host/port/encryption: try 587 + TLS (STARTTLS) first; if your provider requires it, use 465 + SSL. Confirm the exact SMTP host (e.g., smtp.gmail.com, smtp.sendgrid.net). Provider settings checklist
  3. Remove network blocks: ask your host to allow outbound SMTP to your provider on 587/465. If they won’t, switch to an API mailer (Gmail/Microsoft/SendGrid). Why hosts block SMTP
  4. Cloudflare/DNS: make SMTP‑related records DNS‑only (gray cloud) and verify they point to the correct mail server (not proxied). Cloudflare notes

If the quick path didn’t resolve it, click Continue Chat below and I’ll run an automatic environment check with you (ports, DNS, encryption), then proceed with the steps.

Why you’re seeing this

SMTP connect() failed / Could not connect to SMTP host means WordPress could not open a TCP connection to your SMTP server. Common reasons: blocked outgoing ports, wrong host/port/encryption pairing, or DNS/proxy issues. Authentication errors are different (they happen after connecting). See WP Mail SMTP’s explanation and Debug Events.

Symptoms → Likely cause → First check

Symptom (Debug Events) Likely cause First check
“Connection timed out (110) Host/WAF blocking outbound SMTP Ask host to allow 587/465 to your SMTP host; retest Email Test
“Connection refused (111) Port closed/denied on remote host Try the provider’s supported port/encryption; confirm host name
getaddrinfo / DNS failed Wrong hostname or proxied DNS (Cloudflare) Use provider’s exact SMTP hostname; mark DNS as DNS‑only
TLS handshake/SSL error Wrong encryption or CA trust issue Switch 587↔465 with TLS/SSL as required; host updates CA bundle

Step‑by‑step (bulletproof)

1) Read the exact failure in Debug Events

  1. WP Mail SMTP → Tools → Debug Events → send a test → click the event row to expand.
  2. Classify: timeout 110 (blocked), refused 111 (closed), DNS/getaddrinfo (hostname), TLS/SSL (encryption/trust). Keep this log for your host. Guide

2) Fix host/port/encryption (very common)

  1. Confirm the SMTP host from your provider (no typos; don’t use a proxied subdomain).
  2. Use 587 + TLS (STARTTLS) first; if your provider requires SMTPS, use 465 + SSL. Settings checklist
  3. Retest with Email Test and re‑check Debug Events.

3) Remove network blocks (hosting/WAF/Cloudflare)

  1. Ask your host to allow outbound SMTP on 587/465 to your SMTP provider. Many shared hosts block external SMTP; use their relay or an API mailer if needed. Background
  2. Cloudflare: set SMTP records to DNS‑only (no proxy) and ensure the record points to the correct mail server. Cloudflare notes

4) Prove DNS or certificate issues

  1. If Debug Events show DNS failures, verify the SMTP hostname resolves correctly (use your provider’s exact host; avoid proxied CNAMEs).
  2. If TLS/handshake errors appear, match the provider’s required encryption/port and ask your host to update CA certificates if needed.

5) Optional: switch to an API mailer (skips blocked ports)

Using Gmail/Microsoft/SendGrid via API avoids outbound SMTP and often improves deliverability. Docs: Gmail mailer, Microsoft 365 / Outlook mailer.

6) Log and verify (safe diagnostics)

Enable WordPress logging while testing (no front‑end display):

/* wp-config.php */
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

Reproduce a test send; check wp-content/debug.log. Docs: Debugging in WordPress. Turn logging off when done.

Verification checklist

  • WP Mail SMTP Email Test = Success (no connection errors).
  • Debug Events show no new timeout/refused/DNS/handshake errors.
  • Outbound ports confirmed open by host or an API mailer is active.
  • Real emails (contact forms, order emails) arrive reliably.

Variants you might see

  • SMTP connect() failed
  • SMTP Error: Could not connect to SMTP host. Connection failed.
  • Connection timed out (110)” / “Connection refused (111)
  • php_network_getaddresses: getaddrinfo failed” (DNS) — example discussion on WordPress.org

FAQ

587 or 465—which should I use?
Start with 587 + TLS. Use 465 + SSL only if your provider requires it. See WP Mail SMTP’s guide.

My host blocks outbound SMTP. What now?
Request an allow‑list for your SMTP host/ports or use your host’s relay. If not possible, switch to an API mailer (Gmail/Microsoft/SendGrid). Why hosts block SMTP · Gmail · Microsoft

The log mentions authentication—does this page still apply?
Could not connect” fails before login; “Could not authenticate” means credentials were rejected after connecting. Use Debug Events to confirm which case you’re in and follow the relevant guide. Explanation · Debug Events

Still stuck? Click Continue Chat below and I’ll walk you through your Debug Events, host port checks, and the fastest working mailer for your setup.

Need human WordPress help?

WP Assistant is a free tool created by Atiba Software, a WordPress design and development company located in Nashville, TN. If you need more personalized WordPress assistance let us know, and we’ll get back to you ASAP!