Email error 554 5.4.0 – What is it, and what are its causes
554 5.4.0‘ is a email bounce error that is usually seen after a server migration or a mail server reconfiguration.
A typical email bounce looks like this:
host xxx.xxx.xxx.xxx[yyy.yyy.yyy.yyy] said: 554 5.4.0 id=03742-03-6 - Rejected by next-hop MTA on relaying, from MTA(smtp:[zzz.zzz.zzz.zzzz]:31142): 554 5.4.0 Error: too many hops (in reply to end of DATA command)
What is mail error 554 5.4.0?
In a normal mail delivery, mail goes from sender, to the sending MX, to the recipient’s MX and then to the receiver. That is 2 “hops”.
That said, there can be additional servers in between for anti-spam, corporate gateway, load balancers, etc.
It means there could be more hops (up to 10 or 15) based on how the sender and receiver SMTP servers are configured.
However, server misconfigurations are known to cause mails to be stuck in a loop – that is mail keep going in circles between servers, and never get delivered to the recipient.
To prevent such “loops” most mail servers discard (aka bounce) a mail if there are 20 or more “hops”.
554 5.4.0 is used to denote such a situation.
What causes error 554 5.4.0?
A normal healthy mail system should be able to deliver a mail within 20 hops.
However, that limit can get exhausted when:
- Mail gets stuck in a sending loop – We’ve seen improperly configured sender MX or mail gateways forwarding mails back to the sender, causing a mail loop.
- Too many headers are added by intermediate servers – Anti-spam servers or gateway clusters can inject too many headers that’ll be interpreted as a mail loop.
Let’s take a look at these points in more detail.
1. Mail loop within Sender’s MX or Gateway
All mail systems depend on destination “pointers” that show where the destination mailbox is.
These pointers include DNS records, mail user databases, host entries, and more.
In a perfectly working system, these pointers route mail perfectly to the destination server.
But all that can break during a mail system overhaul, and direct the mail elsewhere or inwards to the sending server itself.
We’ve seen such situations during:
– DNS & Mail routing errors after hosting account transfers
When a website is transferred to a new server, its MX DNS records and SMTP routing data need to be changed. We’ve seen cases where these changes do not happen – either due to software errors, or due to customized settings that broke during migration. It leads to mail to be bounced between the old and new servers.
– Mail config errors after server migrations
During server upgrades or infrastructure migrations, mail servers may need to be reconfigured with new IPs and routing tables. We’ve seen issues where routing tables were misconfigured which caused mails to keep connecting back to the sender server, thereby creating a loop.
– Gateway or anti-spam server installation/upgrades
Some companies put a separate anti-spam server or a mail gateway to improve mail filtering. But if the DNS settings and outgoing mail routes are not configured correctly, mails will bounce between the sender’s MX and the gateway.
To resolve these issues, we enable debugging, and trace the error to the exact setting that’s causing the failure.
If you suspect your mail server config is at fault and need help troubleshooting this error, click here to talk to our server experts. We are online 24/7 and can help you within minutes.
2. Too many headers added by intermediate servers
A “Received:” header gets added to a message whenever it passes through a mail server, mail gateway or an anti-malware program.
To prevent mail loops (that is mail never getting delivered), mail servers bounce a mail if the number of “Received:” headers cross 20.
An example of such an error is:
Too many "Received" headers - suspected mail loop
In almost all cases, this error could point to an actual mail loop as we’ve discussed in the previous point.
But there are systems where a mail is processed by many different programs and can inject more than 20 headers.
For eg. the mail will first go to the sender’s MX, then a spam filter, an anti-virus, a DNSBL check tool, a routing server and a mail gateway. All this can add up to 10 “Received:” headers. If the receiving mail server is also similarly configured, the mail could be categorized as a loop.
In such cases, we configure the security tools to print less headers and by combining all functions (antispam, antivirus, external DB check, etc.) into a single tool.
554 5.4.0 can be caused due to improper mail server configuration or anti-spam tool configuration. Here we’ve discussed the two main causes for this error, and how we fix them. If you are having a hard time figuring out the exact cause for this failure then click here to talk to our server experts and get a quick fix for your issue.