Skip to content

How to Fix Exim Email Delivery Failure Error

DodaTech Updated 2026-06-24 2 min read

In this tutorial, you'll learn about How to Fix Exim Email Delivery Failure Error. We cover key concepts, practical examples, and best practices.

Exim mail delivery fails with remote host address is the local host or Connection refused — the router or transport configuration is incorrect for delivering to external domains.

The Problem

2026-06-24 10:00:00 [1234] H=mail.recipient.com [10.0.0.1]:
Connection timed out
2026-06-24 10:00:00 [1234] ** user@recipient.com:
R=lookuphost T=remote_smtp: SMTP error: connection timed out

Step-by-Step Fix

Step 1: Check the mail queue

sudo exim -bp

Step 2: View message details

sudo exim -Mvl QUEUE_ID

Step 3: Force delivery attempt

sudo exim -q -v

Step 4: Test DNS resolution

host recipient.com
dig mx recipient.com

Step 5: Check routers configuration

# /etc/exim4/conf.d/router/200_exim4-config_primary
begin routers

dnslookup:
  driver = dnslookup
  domains = ! +local_domains
  transport = remote_smtp
  ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8
  no_more

Step 6: Check transports configuration

begin transports

remote_smtp:
  driver = smtp
  port = 25
  hosts_require_auth = <; ;
  hosts_require_tls = <; ;

Step 7: Flush queue

sudo exim -qff

Prevention Tips

  • Monitor queue length with sudo exim -bpc
  • Set queue_run_max to control parallel deliveries
  • Configure retry rules in /etc/exim4/conf.d/retry/retry.conf
  • Use exiwhat to check Exim process status

Common Mistakes with delivery fail

  1. Misunderstanding that String is [Char] with poor performance for large text operations
  2. Using foldl instead of foldl' causing stack overflow on large lists
  3. Forgetting deriving (Show, Eq) on custom data types needed for debugging

These mistakes appear frequently in real-world EXIM code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### Why does Exim say "remote host address is the local host"?

Exim detected that the destination MX record resolves to the local server's IP address. This creates a loop. Check /etc/exim4/conf.d/router/200_exim4-config_primary for ignore_target_hosts and add the server IP to the self list or local_domains.

How do I force Exim to retry all deferred messages?

Run sudo exim -qff to force a queue flush, attempting delivery of all messages including frozen ones. For a normal flush (only non-frozen), use sudo exim -q. Monitor the results with sudo exim -bp.

How do I remove a stuck message from the Exim queue?

Use sudo exim -Mrm QUEUE_ID to remove a specific message. To freeze a stuck message for analysis: sudo exim -Mf QUEUE_ID. To thaw a frozen message: sudo exim -Mt QUEUE_ID.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro