BillionMail icon indicating copy to clipboard operation
BillionMail copied to clipboard

failed to connect: SMTP dial: dial tcp: lookup postfix on 127.0.0.11:53: server misbehaving

Open paschalogu opened this issue 6 months ago • 2 comments

Trying to send a test email and getting the response below:

failed to connect: SMTP dial: dial tcp: lookup postfix on 127.0.0.11:53: server misbehaving

So I checked Setting, and /billionmail-postfix-billionmail-1 is stopped

Image

How to fix this?

paschalogu avatar Jun 09 '25 14:06 paschalogu

Is there any error in starting using this command? Is the port used by postfix occupied? docker compose up -d

aaPanel avatar Jun 10 '25 04:06 aaPanel

📨 Fixing Postfix Only Listening on 127.0.0.1:25 (for Billionmail Docker)

This guide explains how to fix the issue where your Postfix container (billionmail-postfix-billionmail) only listens on localhost (127.0.0.1:25) instead of all network interfaces (0.0.0.0:25). It also shows how to prevent the problem permanently by setting the correct environment variables in your docker-compose.yaml.


🚨 Problem

When you run:

netstat -tulnp | grep :25

You see:

tcp  127.0.0.1:25  LISTEN  2366/master
tcp6 ::1:25        LISTEN  2366/master

➡️ This means Postfix is only accepting SMTP connections locally. Other containers or external hosts cannot send mail to this instance — often causing the Docker mail service to fail or stop.


🎯 Goal

We want Postfix to listen on all network interfaces:

tcp  0.0.0.0:25  LISTEN  master
tcp6 :::25       LISTEN  master

🧭 Step 1: Check if the container is running

docker ps | grep billionmail-postfix

If it’s stopped, start it:

docker start billionmail-postfix-billionmail

🧭 Step 2: Enter the container

docker exec -it billionmail-postfix-billionmail bash

🧭 Step 3: Inspect Postfix configuration

Inside the container, check this:

grep inet_interfaces /etc/postfix/main.cf

You’ll likely see:

inet_interfaces = loopback-only

That’s the root cause — Postfix is bound only to localhost.


🧩 Step 4: Fix the configuration

Run:

sed -i 's/^inet_interfaces.*/inet_interfaces = all/' /etc/postfix/main.cf

Verify the change:

grep inet_interfaces /etc/postfix/main.cf

Output should be:

inet_interfaces = all

If the line didn’t exist, add it manually:

echo "inet_interfaces = all" >> /etc/postfix/main.cf

🧩 Step 5: Enable IPv6 support

Make sure this line exists:

inet_protocols = all

If not:

echo "inet_protocols = all" >> /etc/postfix/main.cf

⚙️ Step 6: Restart Postfix

Inside the container:

supervisorctl restart postfix || service postfix restart

Or from the host:

docker restart billionmail-postfix-billionmail

🧪 Step 7: Verify the result

On the host:

netstat -tulnp | grep :25

You should now see:

tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      master
tcp6       0      0 :::25                   :::*                    LISTEN      master

✅ Postfix is now listening on all interfaces.


🧱 Step 8: Permanent fix — set in docker-compose.yaml

To make this change persistent, update your docker-compose.yml.

Example before:

version: "3.8"
services:
  billionmail-postfix:
    image: billionmail/postfix:latest
    container_name: billionmail-postfix-billionmail
    restart: always
    ports:
      - "25:25"
    environment:
      - MAILNAME=mail.example.com
      - MYNETWORKS=127.0.0.0/8 172.17.0.0/16

✅ Add environment variables for interface and protocol:

version: "3.8"
services:
  billionmail-postfix:
    image: billionmail/postfix:latest
    container_name: billionmail-postfix-billionmail
    restart: always
    ports:
      - "25:25"
    environment:
      - MAILNAME=mail.example.com
      - MYNETWORKS=127.0.0.0/8 172.17.0.0/16
      - INET_INTERFACES=all
      - INET_PROTOCOLS=all

🔄 Step 9: Apply changes

Recreate the container:

docker-compose down
docker-compose up -d

Verify:

docker exec -it billionmail-postfix-billionmail bash -c "grep inet_interfaces /etc/postfix/main.cf"

Expected output:

inet_interfaces = all

💡 Step 10: Operational Recommendations

Topic Recommendation
Issue Postfix only listening on localhost
Cause Default inet_interfaces=loopback-only
Temporary fix Manually edit /etc/postfix/main.cf
Permanent fix Add INET_INTERFACES=all in docker-compose.yml
Security tip If only other Docker containers need access, restrict with MYNETWORKS=172.17.0.0/16 instead of exposing globally
Verification Periodically check using `netstat -tulnp grep :25orss -ltnp`
Restart safely Use docker restart billionmail-postfix-billionmail after config edits

Summary:

  • Problem: Postfix bound only to 127.0.0.1:25
  • Fixed by: Setting inet_interfaces = all
  • Permanent fix: Add INET_INTERFACES=all in Docker environment
  • Result: netstat shows Postfix listening on 0.0.0.0:25 and :::25

anhhai986 avatar Oct 12 '25 09:10 anhhai986