Firewall blocks outgoing email

On my Debian server running a Django website, I have an error when I need to send an email.

The error received is

Exception Type: gaierror Exception Value:

[Errno -2] Name or service not known

Exception Location: /usr/lib/python2.6/socket.py in
create_connection, line 547

You can see the full error log here.

After testing, it seems it is my firewall that blocks the request. You can see my iptable file (/etc/init.d/firewall). I think the problem comes from the two commented lines that were supposed to accepts all established connections.

When I uncomment them, I have an error iptables: No chain/target/match by that name.

Thank you

Answer

Seems like error with DNS on your server or hostname in your Django config.

Check EMAIL_HOST in settings.py. If not explicitly set than it is equal to localhost. If domain seems to be ok (exists or equals to localhost) problem lies in DNS resolution (either DNS server does not work properly or your firewall blocks connects to it).

To ensure problem is within firewall, set default policies of INPUT, FORWARD and OUTPUT chains to ACCEPT:

iptables -t filter -P INPUT ACCEPT
iptables -t filter -P FORWARD ACCEPT
iptables -t filter -P OUTPUT ACCEPT

and check whether problem still exists.

Attribution
Source : Link , Question Author : Martin Trigaux , Answer Author : Vadym S. Khondar

Leave a Comment