Errors

SMTP 554 5.4.0: what it means and how to fix it

Short answer

554 5.4.0 means a network or routing problem stopped delivery. The most common version is Postfix's "554 5.4.0 Error: too many hops": the message carried more Received headers than the server allows (50 by default), which signals a mail loop. Find the loop by reading the Received headers, then fix the forwarding rule, MX record or relay setting that sends mail in a circle.

Last checked 16 November 2026

554 5.4.0 is a permanent routing error. The standard meaning is vague, but in practice it is most often Postfix’s “too many hops” reply: the message passed through so many servers that Postfix decided it must be stuck in a loop. Find the loop in the headers and break it.

The error message

From the Postfix source, the reply for a message over the hop limit is:

554 5.4.0 Error: too many hops

Postfix’s hopcount_limit setting is documented as “The maximal number of Received: message headers that is allowed in the primary message headers. A message that exceeds the limit is bounced, in order to stop a mailer loop.” The default is 50.

What it means

In RFC 3463, X.4.0 is “Other or undefined network or routing status”: something went wrong with networking or routing that no more specific code describes. 554 in RFC 5321 is “Transaction failed”.

Every mail server that handles a message adds a Received: header. RFC 5321 notes that counting those headers is an effective way to detect loops, and recommends a large threshold, normally at least 100. Postfix uses 50. When the count passes the limit, the server stops the loop by bouncing the message instead of passing it on again.

Why it happens

  • Forwarding rules that point at each other, for example mailbox A forwards to B and B forwards to A.
  • An MX record pointing to the wrong server, which hands mail back to the server that sent it.
  • A relay host set to itself, or a server that is both told to accept and to relay the same domain.
  • Two systems both claiming a domain, such as an old on-premises server and a new cloud provider during a migration.
  • Auto-replies or ticket systems answering each other.
  • Other 5.4.0 cases: some servers use 5.4.0 for DNS or routing failures with their own text.

How to fix it

  1. Get the full headers of the bounced message (attached to the bounce, or in Show original).
  2. Read the Received: lines from the bottom up. You will see the same servers repeat. Note where the repeating pattern starts.
  3. Check forwarding. Look for mailbox forwarding, aliases and server rules that send to an address which sends back.
  4. Check the MX record for the recipient domain:
    dig MX example.com +short
    Make sure it points to the server that should finally store the mail, not a relay that forwards back.
  5. Check relay settings on your own server, such as Postfix relayhost and transport maps, so a domain is either delivered locally or relayed, not both.
  6. During migrations, make sure only one system treats the domain as its own, and the other forwards to it.
  7. Stop auto-reply loops by having automated mail send Auto-Submitted: auto-generated (RFC 3834) and by not replying to messages that carry it.
  8. Raise hopcount_limit only if a legitimate path really needs more than 50 hops, which is rare.

Which server sent it

Provider Loop reply
Postfix servers 554 5.4.0 Error: too many hops
Gmail 554 5.4.6 Message exceeded 50 hops, this may show a mail loop.
Microsoft Routing loop: 5.4.6 (on-premises Exchange) or 5.4.14 (Exchange Online). Exchange breaks a loop after 20 iterations.
Yahoo Not listed by number.
Other servers X.4.0 for other routing problems, with their own text.

Is it temporary?

No. 554 is permanent, and the message will not be retried. Resending without fixing the loop produces the same bounce, and may put more load on the servers involved. Fix the routing, then send again.

How Mailcandor handles it

Loops usually live in inbound and forwarding setups. If you receive mail with Mailcandor’s inbound email, you point a domain’s MX at inbound-smtp.us-east-1.amazonaws.com and each message fires an email.received webhook to your app instead of passing through a chain of forwarding rules. For outbound mail, the deliverability coach explains bounces in plain English, and hard bounces are suppressed automatically. Look up any code with the free bounce code lookup, see SPF, DKIM and DMARC setup, or browse all error codes. More free checks are on the tools page.

Questions

What does 554 5.4.0 error too many hops mean?

The message passed through more mail servers than the receiving Postfix server allows, counted by Received headers. The default limit is 50. It almost always means the message is looping.

What causes a mail loop?

Two forwarding rules pointing at each other, an MX record that points back to the sending server, or a server that relays mail for a domain to itself. Auto-replies answering each other can also loop.

How do I find where the loop is?

Open the bounced message's headers and read the Received lines from the bottom up. The same few servers repeat in a cycle; the step where the cycle starts is the misconfiguration.

Does Gmail use 554 5.4.0?

No. Gmail reports loops as 554 5.4.6, "Message exceeded 50 hops, this may show a mail loop". Microsoft uses 5.4.6 or 5.4.14 for routing loops.

Related

Send with someone on your side.

Unlimited domains on every plan, a person before any block, and 3,000 emails a month free. Tell us what you send and we set you up within one business day.