Score:1

Postfix is not working? Telnet connection refused when testinf

sv flag

I am attempting to get postfix working on Ubuntu Server 22.04 for send only.

When attempting to test the server using telnet mydomain.com 587, I get the following

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

However when using telnet localhost 587 or telnet 127.0.0.1 587 I get

Trying 127.0.0.1... 
Connected to localhost. Escape character is '^]'. 
Connection closed by foreign host.

Running netstat -plntu I get (Note this is the most current netstat)

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      730/sshd: /usr/sbin
tcp        0      0 0.0.0.0:23              0.0.0.0:*               LISTEN      652/inetd
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      633/systemd-resolve
tcp        0      0 0.0.0.0:587             0.0.0.0:*               LISTEN      2126/master
tcp6       0      0 :::22                   :::*                    LISTEN      730/sshd: /usr/sbin
tcp6       0      0 :::587                  :::*                    LISTEN      2126/master
udp        0      0 127.0.0.53:53           0.0.0.0:*                           633/systemd-resolve
udp        0      0 0.0.0.0:50550           0.0.0.0:*                           654/meshagent
udp6       0      0 fe80::214:22ff:fe7c:546 :::*                                620/systemd-network

sudo iptables -L INPUT -n -v
Chain INPUT (policy DROP 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
   22  1914 ufw-before-logging-input  all  --  *      *       0.0.0.0/0            0.0.0.0/0
   22  1914 ufw-before-input  all  --  *      *       0.0.0.0/0            0.0.0.0/0
   14  1338 ufw-after-input  all  --  *      *       0.0.0.0/0            0.0.0.0/0
    1    96 ufw-after-logging-input  all  --  *      *       0.0.0.0/0            0.0.0.0/0
    1    96 ufw-reject-input  all  --  *      *       0.0.0.0/0            0.0.0.0/0
    1    96 ufw-track-input  all  --  *      *       0.0.0.0/0            0.0.0.0/0

sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
22                         ALLOW       Anywhere
587                        ALLOW       Anywhere
Postfix                    ALLOW       Anywhere
25                         ALLOW       Anywhere
22 (v6)                    ALLOW       Anywhere (v6)
587 (v6)                   ALLOW       Anywhere (v6)
Postfix (v6)               ALLOW       Anywhere (v6)
25 (v6)                    ALLOW       Anywhere (v6)

I currently have the firewall disabled for testing purposes. Once I get this resolved I will reenable the firewall.

Anyone have any ideas what the issue could be, or have a direction I can go.

Thank you for any and all assistance.

in flag
Welcome to AskUbuntu. Where is the server being hosted? On premise? AWS? Azure? Elsewhere?
amd.64 avatar
sv flag
On premises, self hosted.
Score:0
uy flag

64 You postfix listens on the loopback interface only. You may see this in the output of the netstat command. 127.0.0.1:587 IPv4 loopback, ::1:587 IPv6 loopback each with port 587.

Have a look at the configuration file /etc/postfix/main.cf

There is a parameter named inet_interfaces. Your value of this parameter is seems to be 127.0.0.1, ::1 (or similar) You may change this towards

inet_interfaces = all

after a restart the postfix Daemon will listen on all interfaces.

amd.64 avatar
sv flag
One of the guides I followed said to set that to loopback. Seemed weird to me but I was using the guide for a reason. I seen in another post someone had the same issue and where given the same answer you did, so I changed it and restarted postfix, but I still had the same problem. I am rebooting the server now.
dummyuser avatar
uy flag
please add a new `netstat -anp` to your question.
amd.64 avatar
sv flag
I have rebooted the server with the change suggested above. However connections are stiill being closed by foreign host.
amd.64 avatar
sv flag
Question update with current netstat -plntu. netstat -anp is extensive
dummyuser avatar
uy flag
`netstat -anp | grep master | grep -v LISTENING | grep -v CONNECTED ` is fine.
amd.64 avatar
sv flag
tcp 0 0 0.0.0.0:587 0.0.0.0:* LISTEN 2126/master tcp6 0 0 :::587 :::* LISTEN 2126/master unix 2 [ ] DGRAM 23961 2126/master public/postlog
dummyuser avatar
uy flag
the entry in the netstat output did change from 127.0.0.1:587 to 0.0.0.0:587. You listen on all interfaces on port 587. if you cannot connect check the firewall / routing. firewall `iptables -L INPUT -n -v` . Routing: I can not comment the setup.
amd.64 avatar
sv flag
If it helps doing a nmap scan from another computer shows that port 587 is open iptables -L INPUT -n -v add to the question.
dummyuser avatar
uy flag
your computer seems to have the IP 192.168.107.11 correct? if so try `telnet 192.168.107.11 587` from where are you testing ? a 2nd computer inside the same Network or from somewhere out of the internet?
amd.64 avatar
sv flag
Correct the server IP address is 192.168.107.11 (Static) Attempting to telnet with putty in Windows by IP address or FQDN I get Network error: Software caused connection abort. Attempting to connect through SSH or directly from the server by IP, localhost, FQDN or loopback I get error as described earlier. Everything thus far has been tried locally, no VPN etc. Both server and computer(s) connecting from on same network.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.