Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
    
And when you specify the table explicitly? –  Ignacio Vazquez-Abrams Mar 25 '12 at 16:18
    
you mean with iptables -t filter -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT ? Same result –  Martin Trigaux Mar 25 '12 at 16:26

1 Answer 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.

share|improve this answer
    
When I open the firewall with the rules you give, the email is sent. –  Martin Trigaux Mar 25 '12 at 16:21
    
And in the django config, the email_host is set to the smtp server. –  Martin Trigaux Mar 25 '12 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)? –  Vadym S. Khondar Mar 25 '12 at 17:17
    
Also, what is output of sysctl net.netfilter.nf_conntrack_acct? –  Vadym S. Khondar Mar 25 '12 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 –  Martin Trigaux Mar 25 '12 at 17:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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