How to Fix Exim Router Configuration Error
In this tutorial, you'll learn about How to Fix Exim Router Configuration Error. We cover key concepts, practical examples, and best practices.
Exim returns Unrouteable address or router = lookuphost generated 127.0.0.1 — the router configuration is incorrect, causing Exim to deliver mail to the wrong destination or loop back to itself.
The Problem
2026-06-24 10:00:00 [1234] ** user@example.com: Unrouteable address
Step-by-Step Fix
Step 1: Check router ordering
# /etc/exim4/conf.d/router/
# Routers are processed in order. First match wins.
# 100 - dnslookup (external domains)
# 200 - manualroute (specific routes)
# 300 - redirect (aliases)
# 400 - localuser (local delivery)
Step 2: Fix DNS lookup router
# /etc/exim4/conf.d/router/200_exim4-config_primary
dnslookup:
driver = dnslookup
domains = ! +local_domains
transport = remote_smtp
ignore_target_hosts = <; 0.0.0.0 ; 127.0.0.0/8 ; ::1
no_more
Step 3: Fix manualroute router
manualroute:
driver = manualroute
domains = *.example.com
transport = remote_smtp
route_data = $domain
route_list = "* mail.example.com byname"
self = send
Step 4: Fix redirect (alias) router
system_aliases:
driver = redirect
allow_fail
allow_defer
data = ${lookup{$local_part}lsearch{/etc/aliases}}
redirect_router = dnslookup
Step 5: Test routing
sudo exim -bt user@example.com
Expected:
router = dnslookup, transport = remote_smtp
host mail.recipient.com [192.0.2.1] MX=10
Step 6: Check for routing loops
sudo exim -bt user@localdomain.com
# Should not generate the server's own IP
Prevention Tips
- Use
exim -btto test routing before changing configs - Add
no_moreto terminal routers to prevent fall-through - Order routers from most specific to most general
- Use
self = sendorself = freezeto control loop behavior
Common Mistakes with router error
- Mixing let bindings with <- bindings in do notation, producing type errors
- Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors
- Non-exhaustive pattern matches that compile with warnings then crash at runtime
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
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro