1

I have installed postfix following this tutorial but when I try to telnet mail.mydomain.com 110 (995,993,143 or 25) it throws the following error: Telnet: Unable to connect to remote host: Connection refused

I looked at this answer of ServerFault but it couldn't help! Any clue how to fix this (or a link to another tutorial), I've been trying to install a servermail on my VPS for a week now, cannot get it to work!

  • 2
    Verify the name resolves to what you'd expect (ping mail.mydomain.com and check the IP), check that you can telnet out at all (try telnet to your ssh port), see if it fails immediately (probably not listening) or if it takes a while (probably firewall dropping the packets), see if it's listening on the correct port (lsof -i:110 etc) – Smiling Dragon Jun 9 '15 at 4:42
  • @EEAA well I tried to change chroot in master.cf from - into n as it was suggested in the answer I looked up, I tried to changed smtp inet n - - - - smtpd with 0.0.0.0:smtp inet n - - - - smtpd... but nothing seemed to work! Thanks – Waiyl Karim Jun 9 '15 at 19:58
  • @SmilingDragon when I ping my mail subdomain it works fine, but when I try to telnet MY_VPS_IP_ADDRESS 25 it throws the same error above, but when I telnet localhost 25 it works fine! Any idea? Thanks – Waiyl Karim Jun 9 '15 at 20:01
  • My recommendation to use ping is to obtain the IP address, the actual ping result isn't interesting. You want to make sure that the name resolves to the same IP address that you think you are on. – Smiling Dragon Jun 9 '15 at 21:22
  • If it works when you telnet to localhost but not to the NIC, it's probably a binding issue. You can see which interfaces it's listening on by running lsof -i -a -p <pid of postfix> (or netstat -an | grep 25 if you lack lsof). – Smiling Dragon Jun 9 '15 at 21:24
0

Run nmap on the IP address that the name mail.example.com resolves to. Nmap will list all open ports on the machine.

In the /etc/postfix/master.conf under the smptd you can add ports

| improve this answer | |
  • nmap MY_SERVER_IP shows 25/tcp open smtp and 110/tcp open pop3 (and others) well I tried to change smtp inet n – n – – smtpd in /etc/postfix/master.conf into 25 inet n – n – – smtpd and service postfix restart but still cannot telnet mail.example.com 25 Any suggestions? Thanks – Waiyl Karim Jun 9 '15 at 20:12
  • The line you add to the master.cf should read like: smtp inet n - - - - smtpd – Peter Nduati Jun 10 '15 at 5:55
0

Connection refused means the machine responded but something is blocking the communication. It's nearly always the firewall. Check your firewall settings to make sure telnet and SMTP traffic is allowed:

https://help.ubuntu.com/community/UFW

If you're not in a production environment where things need to be secure at all times you can try temporarily disabling your firewall (if enabled) to see if it works. If it works with your firewall down then it's the firewall blocking it.

Postfix can be complicated to setup if you don't know what you're doing. You'll also need to setup Dovecot if you want to check mail via IMAP or POP3.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.