-1

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

2
  • And when you specify the table explicitly? Mar 25, 2012 at 16:18
  • you mean with iptables -t filter -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT ? Same result Mar 25, 2012 at 16:26

1 Answer 1

1

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.

7
  • When I open the firewall with the rules you give, the email is sent. Mar 25, 2012 at 16:21
  • And in the django config, the email_host is set to the smtp server. Mar 25, 2012 at 16:30
  • Your iptables config seems to be correct, and yes, without rules allowing established connections it will block. So the task is to now what's wrong with those rules for iptables in your setup. Not very informative message iptables: No chain/target/match by that name. is known to happen when iptables finds option of not implicitly known module or if particular module does not exist. What is version of debian you're running on? Are there state and conntrack modules in kernel (may by checked with 'ls /lib/modules/uname -r/kernel/net/netfilter/ | grep "(state|conn)"')? Are they loaded (lsmod)? Mar 25, 2012 at 17:17
  • Also, what is output of sysctl net.netfilter.nf_conntrack_acct? Mar 25, 2012 at 17:18
  • Strangely I don't have modprobe and lsmod. And no folder /lib/modules. I have a debian 5 on a OpenVZ server, they maybe use a custom kernel. uname -r returns 2.6.32-6-pve Mar 25, 2012 at 17:58

You must log in to answer this question.

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