Australian cloud for business software — built and run in Sydney since 2002

NetLeverage
NetLeverage

Exchange Online NDR '5.4.14 Hop count exceeded - possible mail loop ATTR34' after a hybrid or connector change

Technical article
Troubleshooting

About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.

The bounce "5.4.14 Hop count exceeded - possible mail loop ATTR34" is always generated by Exchange Online, according to Microsoft. Its on-premises twin, "554 5.4.6 Hop count exceeded - possible mail loop", is always generated by on-premises Exchange servers. Both carry the words "possible mail loop", and Microsoft says the cause is likely the message hop count being exceeded or the route through which the message is delivered being broken. Microsoft names two areas to check: the accepted domain configuration, and, in a hybrid deployment, the connectors between Exchange Online and your on-premises Exchange.

Microsoft says these issues are fixed by an Exchange Online admin, not by the person who sent the message. A sender who gets the bounce should forward it to the admin.

What the error means

Microsoft's page says its information applies to a range of error codes, 5.4.6 through 5.4.20, and lists 5.4.6 and 5.4.14 as the "Hop count exceeded - possible mail loop" codes. It says 5.4.6 indicates a mail loop or routing problem in on-premises Exchange Server, which you would likely encounter in a hybrid environment. 5.4.14 indicates a mail loop or routing problem in Exchange Online.

For 5.4.14 the page gives two possibilities. Based on the domain in the recipient's address, your Exchange Online organisation accepted the message but could not route it correctly to the recipient. The page says this failure is likely caused by accepted domain configuration issues. Or, in a hybrid environment, connectors in your Exchange Online organisation are misconfigured.

Microsoft documents no hop limit for this code. What its page does give is where to look, which depends on the code. A 5.4.14 bounce means start with Exchange Online. A 5.4.6 bounce means the on-premises servers generated it. The steps here are written for the first case; for a 5.4.6 bounce, start on the on-premises servers.

Likely causes

Cause What you see How to confirm
Recipient's domain is not configured as an authoritative accepted domain, the check Microsoft gives Bounce for recipients in one domain Domain type in Mail flow, Accepted domains
MX points to Exchange Online, and the Exchange Online to on-premises connector uses DNS routing Bounce for recipients on-premises Connector routing is not a smart host
All outgoing mail is routed through the on-premises server, and there is no connector from Office 365 to your server of type On-premises Bounce on outbound mail via on-premises RouteAllMessagesViaOnPremises is True and the connector list lacks an On-premises type
The Office 365 to your-server connector is scoped to accepted domains Same Scope shows accepted domains

Prove the cause before changing anything

All of these only read. The commands that save output write a file in the current folder, which is the record you go back to if you change anything.

Start with the accepted domain of the recipient. In Exchange Online PowerShell:

Get-AcceptedDomain -Identity contoso.com.au | Format-List
Get-AcceptedDomain | Format-List Name,DomainName,DomainType | Out-File -FilePath .\accepted-domains-before.txt

Next, save the connectors in both directions, because the Fix section may change them:

Get-OutboundConnector | Format-List | Out-File -FilePath .\outbound-connectors-before.txt
Get-InboundConnector | Format-List | Out-File -FilePath .\inbound-connectors-before.txt

Microsoft describes two domain types in Exchange Online. Authoritative means mail is delivered to addresses listed for recipients in Microsoft 365, and mail for unknown recipients is rejected. Internal relay means recipients can be in Microsoft 365 or on your own servers, and mail for unknown recipients is relayed to your server. Microsoft says that with Internal relay you must create a connector from Microsoft 365 to your on-premises server, otherwise recipients not hosted in Microsoft 365 cannot receive mail on your servers. Compare the type with where your recipients actually live.

Then check the routing option. For the connector used for hybrid, in the Exchange admin center go to Mail flow, then Connectors, select the hybrid connector and under Routing choose Edit routing to view the smart host. Close the screen without saving. To see whether all outgoing mail goes through on-premises:

Get-OutboundConnector -Identity "Outbound to Contoso on-premises" | Format-List Name,RouteAllMessagesViaOnPremises

Microsoft says that when RouteAllMessagesViaOnPremises is $true, you are routing all outgoing mail from Exchange Online through your on-premises hybrid server. In that case also check the connector from Office 365 to your organisation's email server: its Connector Type must be On-premises, and under Scope the accepted domains must be empty.

Example (illustrative): Contoso has 120 mailboxes, 80 in Exchange Online and 40 on mail01.contoso.com.au in a hybrid setup. After a change, mail to the 40 on-premises users bounces with 5.4.14, while mail to the 80 cloud users works. So 40 of 120, or 33 per cent, of recipients are affected. The pattern points at the connector from Exchange Online to the on-premises server, not at the domain. A check shows it uses DNS routing, and the MX record for the hybrid domain points to Exchange Online.

Fix

For the hybrid cases Microsoft calls rerunning the Hybrid Configuration Wizard in your on-premises Exchange organisation the easiest way to fix the problem. The alternative is to correct the connector by hand and verify it step by step.

Disruptive step: rerunning the Hybrid Configuration Wizard changes hybrid configuration. Microsoft documents no list of the settings the wizard changes and no way to undo it. Save-first: outbound-connectors-before.txt, inbound-connectors-before.txt and accepted-domains-before.txt from the read-only step, plus screenshots of the connectors in the Exchange admin center. There is no tested way back from the wizard. If you see afterwards that the wizard changed a setting on a connector that still exists, you can set it back with Set-OutboundConnector -Identity "Connector name" or Set-InboundConnector -Identity "Connector name" using the values in the saved files. A connector the wizard created or removed cannot be restored that way. If you cannot accept that risk, use the manual connector edit below, which changes one connector at a time against its own recorded values.

For the MX-to-Exchange-Online case.

Save first: the two connector files from the read-only step.

Disruptive step: the connector steps in this case and in the route-all-outgoing case below edit a connector, or create a second one next to an existing hybrid connector, and either changes live mail routing for everything that uses it.

If the MX record points to Exchange Online and the connector from Exchange Online to on-premises uses DNS routing, configure a dedicated connector for hybrid. It will use smart host routing, with your on-premises hybrid server as the smart host. Check in the EAC that the correct IP address or FQDN is specified for the smart host. This rule belongs to the connector that routes mail from Exchange Online to your on-premises organisation.

For the route-all-outgoing case. Configure a dedicated connector from Office 365 to your organisation's email server with Connector Type On-premises, that is not scoped to any accepted domains. This is a different connector from the one in the previous paragraph. Microsoft's page labels the two connectors' directions in slightly different words in different places, so judge each connector by its Connector Type, scope and smart host values in the saved files, not by its name alone. If a hybrid connector already exists, edit it rather than adding another.

The reference says UseMXRecord $true means the connector uses DNS routing (MX records) and is the default, and $false means it delivers to one or more smart hosts, which requires the SmartHosts value. So the forward change to a smart host is Set-OutboundConnector -Identity "Connector name" -UseMXRecord $false -SmartHosts "mail01.contoso.com.au".

To undo it, for a connector you edited, set the smart host, type and scope back to the values in the file (UseMXRecord, SmartHosts, RouteAllMessagesViaOnPremises, ConnectorType) and save in the EAC, or use PowerShell. The back-out to DNS routing, if the file shows UseMXRecord True, is Set-OutboundConnector -Identity "Connector name" -UseMXRecord $true; if the file shows a different smart host, restore it with -UseMXRecord $false -SmartHosts and the recorded value. For a connector you created, disable it with Set-OutboundConnector -Identity "Connector name" -Enabled $false and then delete it once mail flows as before. The -UseMXRecord, -SmartHosts and -Enabled parameters are on the Set-OutboundConnector reference page.

For the accepted domain case. Verify the recipient's domain is configured as an authoritative accepted domain in Exchange Online, as Microsoft's page says. Changing the type is done under Mail flow, Accepted domains, by selecting the domain and its type. The PowerShell form uses the DomainType parameter, whose reference lists the values Authoritative, InternalRelay and ExternalRelay, the last available only on-premises.

Disruptive step: switching a domain to Authoritative enables Directory-Based Edge Blocking, so mail for recipients not in Microsoft 365 is rejected. Microsoft's accepted domains page says to add recipients first. Do not change a hybrid domain's type without confirming every recipient exists in the cloud directory. Microsoft's 550 5.1.10 page describes Internal Relay as the type that relays mail for recipients not found in Exchange Online to your on-premises organisation, provided the required connector exists, and warns that "changing the accepted domain type might cause other unanticipated problems". Compare the type with where your recipients live before you change it. Save-first: accepted-domains-before.txt from the read-only step. Back-out: run the same command with the recorded type, for example Set-AcceptedDomain -Identity contoso.com.au -DomainType InternalRelay, or set it in Mail flow, Accepted domains.

The command, once the Save-first file exists and every recipient is confirmed in the cloud directory:

Set-AcceptedDomain -Identity contoso.com.au -DomainType Authoritative

Confirm the fix

Send a test message from a cloud mailbox to an on-premises mailbox, and the reverse. Run a message trace in the Exchange admin center under Mail flow, then Message trace, with the sender and recipient added, and confirm both messages show Delivered. Select a message and its Details if one does not, because the details carry an explanation and a How to fix it section. Trace data can take from 10 minutes to an hour to appear, so wait before you decide a test failed. Repeat for each domain that bounced. If the bounce persists, keep the recorded connector output together with the full NDR text and the message trace details, so that whoever you escalate to has the complete picture in one place.

What to watch afterwards

  • Bounces with 5.4.6 from on-premises servers, which indicate the loop is on that side.
  • Changes to accepted domains or connectors. Any change to MX, accepted domain type or connector routing should be followed by a two-way test.
  • Hybrid reruns. Record connector settings before each one.
  • Delivery to subdomains, since Microsoft ties subdomain routing to Internal relay.
  • A written record of the final connector settings, kept with the change ticket, so the next person who edits a hybrid connector can compare against a known good state instead of guessing.

Risks and limits

These commands have not been run or lab-tested. The Get- commands only read configuration and write a file. Set-AcceptedDomain and Set-OutboundConnector change the live domain type and connector, and each has its own save-first step and back-out above. The connector name in the example command is made up, so use the name your tenant shows. The accepted-domain and connector reference pages show no date. Microsoft calls the wizard rerun the easiest way to fix the problem, but it changes configuration widely, so treat it as a planned change in a quiet period.

Sources