Skip to content

How to Fix Exim Router Configuration Error

DodaTech Updated 2026-06-24 2 min read

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 -bt to test routing before changing configs
  • Add no_more to terminal routers to prevent fall-through
  • Order routers from most specific to most general
  • Use self = send or self = freeze to control loop behavior

Common Mistakes with router error

  1. Mixing let bindings with <- bindings in do notation, producing type errors
  2. Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors
  3. 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

### What does "Unrouteable address" mean in Exim?

None of the configured routers accepted the address. Either the domain is not handled by any router, or the routers did not match. Use exim -bt address to trace which router the address matches and why it ultimately fails.

How do I prevent Exim from looping when routing to my own domains?

Set the self option on the router: self = send to deliver directly, self = freeze to freeze the message for manual review, or self = defer to temporarily defer delivery. This prevents the loop.

What is the correct ordering for Exim routers?

Order routers from most specific to most general: aliases first, then domain-specific routes, then DNS lookup, then local delivery. The no_more option on a router prevents processing subsequent routers if this one matched.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro