Helo command rejected: need fully-qualified hostname Email / SMTP Origin: Network Last updated 4 Nov 2026

SMTP: 504 5.5.2 <localhost>: Helo command rejected: need fully-qualified hostname

The receiving server refused your EHLO/HELO greeting because the name you sent is not a valid fully-qualified domain name.

Exact message you may see Helo command rejected: need fully-qualified hostname504 5.5.2 Helo command rejectedHelo command rejected: Host not found501 5.5.4 Invalid domain name HELOHELO command rejected: invalid hostname
Seen on: SMTP Linux

Meaning

Servers with reject_non_fqdn_helo_hostname or reject_invalid_helo_hostname refuse names like localhost, a bare hostname, or an IP without brackets. Set your sender's name to a hostname with a matching A record and PTR, such as mail.example.com.

Common causes

  • HELO is localhost or a short hostname
  • Application using a default hostname from the container
  • HELO name has no DNS record
  • IP literal without square brackets
  • Hostname differs from the PTR record

⚡ Quick fix

  1. Set a proper FQDN as the HELO name (myhostname in Postfix, local_hostname in smtplib)
  2. Make sure the FQDN has A and PTR records
  3. Containers: set the hostname explicitly

Detailed fix by platform

Postfix

  1. postconf -e 'myhostname = mail.example.com' && postfix reload

Python

  1. smtplib.SMTP("smtp.example.com", 587, local_hostname="mail.example.com")

How to diagnose

  1. HELO — Value sent?
  2. DNS — A and PTR exist?
  3. Config — hostname set explicitly?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Network. Errors that are often confused with or caused by this one (click to open):

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 (Email / SMTP)421 4.7.0 Try again l…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 (Email / SMTP)450 4.7.1 Greylisted,…550 5.7.25 PTR record required — SMTP: 550-5.7.25 The IP address sending this message does not have a PTR record setup, or the corresponding forward DNS entry does not point to the sending IP (Email / SMTP)550 5.7.25 PTR record…554 5.7.1 Service unavailable; client host rejected — SMTP: 554 5.7.1 Service unavailable; Client host [203.0.113.5] blocked / 554 5.7.1 <mail.example.com>: Client host rejected: Access denied (Email / SMTP)554 5.7.1 Service una…No MX record / Domain not found — SMTP: 550 5.1.2 Domain not found / 554 5.4.4 Unable to resolve MX / Host or domain name not found (Email / SMTP)No MX record / Domain…Postfix: Host or domain name not found — Postfix: status=deferred (Host or domain name not found. Name service error for name=example.com type=A: Host not found, try again) (Email / SMTP)Postfix: Host or doma…SMTPServerDisconnected: Connection unexpectedly closed — Python: smtplib.SMTPServerDisconnected: Connection unexpectedly closed (Email / SMTP)SMTPServerDisconnecte…Helo comm…

Explore the map of this error Full error map →

🧠 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.