logo
search
Exchange Connection Problems

How to Fix Mail Looping Between On-Premises Exchange and Exchange Online

Steven ParkerSteven Parker Oct 19, 2026 869 views

Question details

The user needs to resolve an issue where emails sent to Exchange Online mailboxes are repeatedly routed back to the on-premises Exchange server, resulting in a mail loop.

How to Fix Mail Looping Between On-Premises Exchange and Exchange Online
Product
Microsoft Exchange
Device & OS
not provided
Scenario
Configuring or troubleshooting hybrid mail flow and outbound connectors between local servers and the cloud.
Observed behavior
Messages continuously bounce back and forth between environments until delivery fails with a 'Hop count exceeded - possible mail loop detected' error.
Before you start

Verify that the affected Exchange Online mailbox is fully active, properly licensed, and not configured with an accidental forwarding rule before altering your global transport rules.

Solution 1Recommended

Verify Exchange Online Outbound Connector Settings

Use this solution to ensure that the outbound connector in Exchange Online is not mistakenly routing all cloud-destined messages back to your on-premises environment.

In a hybrid environment, an improperly configured outbound connector can force mail destined for Exchange Online back to the on-premises gateway. If the gateway doesn't recognize the cloud recipient, it sends it back to Exchange Online, creating an infinite loop.

1
Access Exchange Admin Center

Log into the Microsoft 365 Exchange admin center and navigate to the 'Mail flow' section, then click on 'Connectors'.

2
Inspect the Outbound Connector

Select the connector responsible for routing mail from Microsoft 365 to your organization's email server.

3
Check Routing Configuration

Verify if 'RouteAllMessagesViaOnPremises' is set to True. If it is enabled, ensure your local gateway or SmartHost is configured to recognize Exchange Online recipients and route them to the cloud rather than returning them to on-premises Exchange.

Verify Exchange Online Outbound Connector Settings
PowerShell Alternative: You can also verify this setting by connecting to Exchange Online PowerShell and running the command: Get-OutboundConnector | Format-List.
Free Microsoft Office alternative

Analyze Message Trace Reports Easily with WPS Office

Troubleshooting complex Exchange environments often requires reading extensive CSV files generated by extended message traces. WPS Office provides a lightweight, highly compatible, and free alternative to Microsoft Office, perfect for IT administrators who need a reliable spreadsheet tool without the heavy subscription costs.

  1. 1. Download the Installer: Visit the official WPS Office website and download the free installation package for your operating system.
  2. 2. Install WPS Office: Run the installer and follow the on-screen prompts to set up the lightweight productivity suite on your workstation.
  3. 3. Open CSV Trace Files: Launch WPS Spreadsheet and open your extended message trace CSV files to seamlessly filter and analyze server hop data.
Fully compatible with Microsoft Excel formats (.xlsx, .csv), ensuring seamless reading of Exchange message trace exports.Lightweight and fast installation, ideal for IT environments and administrative workstations.Familiar tabbed interface that requires zero learning curve, allowing you to focus on troubleshooting.Completely free core functionalities for Word, Excel, and PowerPoint alternatives.
microsoft office alternative - wps office

Frequently Asked Questions

What causes the 'Hop count exceeded - possible mail loop detected' error in Exchange?

This error occurs when an email message bounces between servers too many times without reaching its final destination. In hybrid environments, it typically happens when Exchange Online sends an email to an on-premises server, and the on-premises server (or its gateway) routes it right back to Exchange Online due to misconfigured connectors or recipient settings.

How do I find out which server is causing the mail loop?

You can identify the source by running an Extended Message Trace in the Exchange admin center. By downloading the trace as a CSV file, you can inspect each server hop and see exactly which local gateway or cloud connector is making the incorrect routing decision.

Does RouteAllMessagesViaOnPremises always cause mail loops?

No, 'RouteAllMessagesViaOnPremises' is a legitimate setting for organizations that require all outbound cloud mail to be filtered or archived locally. However, if your local email gateway is not configured to recognize that the target mailbox actually resides in Exchange Online, it will bounce the message back to the cloud, creating a loop.