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!

5
  • 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) Jun 9, 2015 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 Jun 9, 2015 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 Jun 9, 2015 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. Jun 9, 2015 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). Jun 9, 2015 at 21:24

2 Answers 2

-1

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

2
  • 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 Jun 9, 2015 at 20:12
  • The line you add to the master.cf should read like: smtp inet n - - - - smtpd Jun 10, 2015 at 5:55
-1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .