Question

Postfix: can't connect to localhost but can connect to 127.0.0.1?

Hello all!

For some reason I can’t seem to connect to postfix using ‘localhost’. The command ‘telnet localhost 25’ returns the following:

Trying 127.0.1.1...
telnet: Unable to connect to remote host: Connection refused

My /etc/hosts file looks as follows:

127.0.1.1 localhost localhost.localdomain
droplet.ip.address.here example.com

::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

/etc/postfix/main.cf (relevant section):

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = localhost
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only
inet_protocols = all

Could anybody help me solve what’s going on?


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

I know, 4 years have passed, but I need respond this haha

Dude, your localhost IP is incorrect… 127.0.1.1 is wrong, the right is 127.0.0.1.

Hello,

Seems like that there is a typo in your /etc/hosts file, you need to change:

127.0.1.1 localhost
```

To:

```
127.0.0.1 localhost
```

Regards,
Bobby