Postfix “Temporary Lookup Failure”: Diagnosing and Fixing Virtual Mailbox Configuration Issues


1 views

When setting up a Postfix mail server with virtual mailboxes, you might encounter two particularly frustrating errors:

451 4.3.0 : Temporary lookup failure
550 5.1.1 : Recipient address rejected: User unknown in local recipient table

The "Temporary lookup failure" typically appears when Postfix can't access required database files. From the journalctl logs:

warning: hash:/etc/aliases is unavailable. open database /etc/aliases.db: No such file or directory
warning: hash:/etc/aliases lookup error for "dzervas@dzervas.gr"

This reveals Postfix is failing to access the aliases database. Even when you're using virtual mailboxes, Postfix still checks the system aliases by default.

The initial solution is straightforward:

# Create an empty aliases file if it doesn't exist
sudo touch /etc/aliases

# Generate the aliases.db file
sudo newaliases

After fixing the aliases issue, you'll likely encounter:

550 5.1.1 : Recipient address rejected: User unknown in local recipient table

This occurs because Postfix is still checking the local recipient table. The solution is to modify your main.cf:

# Disable local recipient checking when using virtual mailboxes
local_recipient_maps =

Even after these fixes, emails might queue but not deliver to the correct virtual mailbox location. Several configuration elements must work together:

# Main virtual mailbox settings
virtual_mailbox_base = /var/mail/vhost
virtual_mailbox_maps = hash:/etc/postfix/vmailbox
virtual_minimum_uid = 1000
virtual_uid_maps = static:2000
virtual_gid_maps = static:2000

# Make sure these are properly set
mydestination = localhost, localhost.$mydomain, $myhostname

Ensure your vmailbox file is properly formatted and compiled:

# Example vmailbox contents
dzervas@dzervas.gr      dzervas.gr/dzervas
dna@dzervas.gr          dzervas.gr/dna

# Compile the map
sudo postmap /etc/postfix/vmailbox

Proper permissions are crucial for virtual mailbox delivery:

# Create the base directory
sudo mkdir -p /var/mail/vhost
sudo chown -R 2000:2000 /var/mail/vhost
sudo chmod -R 700 /var/mail/vhost

After making changes, always test:

# Check Postfix configuration
sudo postfix check

# Reload Postfix
sudo systemctl reload postfix

# Verify virtual mailbox mapping
postmap -q "dzervas@dzervas.gr" hash:/etc/postfix/vmailbox

Ensure all these elements are in place:

  • Properly compiled aliases database
  • Correct virtual mailbox maps and permissions
  • local_recipient_maps disabled when using virtual mailboxes
  • mydestination not including virtual domains
  • Proper filesystem permissions for the virtual mail directory

With these configurations in place, your Postfix virtual mail server should now properly receive and deliver emails to the designated virtual mailboxes.


When configuring Postfix with virtual mailboxes, two critical errors commonly appear:

  • "Temporary lookup failure" during SMTP transactions
  • Mail getting queued but not delivered to virtual mailboxes

The key error in journalctl reveals:

error: open database /etc/aliases.db: No such file or directory
warning: hash:/etc/aliases is unavailable
warning: hash:/etc/aliases lookup error

This indicates Postfix is failing to access the aliases database, which is required even when using virtual mailboxes.

First, create a basic aliases file and compile it:

sudo touch /etc/aliases
sudo newaliases

Then modify main.cf to properly handle virtual delivery:

# Disable local recipient checking for virtual domains
local_recipient_maps =

# Ensure proper virtual mailbox delivery
virtual_mailbox_domains = dzervas.gr, ns0.dzervas.gr
virtual_transport = virtual
virtual_mailbox_limit = 51200000

Your vmailbox file format is correct, but ensure proper permissions:

sudo postmap /etc/postfix/vmailbox
sudo chown -R 2000:2000 /var/mail/vhost
sudo chmod -R 700 /var/mail/vhost

After making these changes, test with:

echo "Test email" | mail -s "Test" dzervas@dzervas.gr
postqueue -p

If mail gets stuck in queue, check master.cf for virtual transport:

virtual   unix  -       n       n       -       -       virtual

While DNS isn't strictly required for local testing, production requires:

dzervas.gr.      IN MX 10 ns0.dzervas.gr.
ns0.dzervas.gr.  IN A  192.0.2.1

Confirm virtual mailbox delivery works:

sudo ls -l /var/mail/vhost/dzervas.gr/dzervas
sudo postconf virtual_mailbox_domains

The key is ensuring all components - aliases, virtual maps, and transport - are properly configured and compiled.