Thursday, June 21, 2012

Error "failed to get a socket for (null)" after upgrading apache httpd

The symptom: After an regular Debian update, when I tried to start apache, it show me this error:

(22)Invalid argument: alloc_listener: failed to get a socket for (null)
...
Syntax error on line xx of /etc/apache2/ports.conf:

The line was
Listen 80

(the error could appear in apache2.conf or httpd.conf too)

I changed it to all known to me forms, but with no success - "*:80", "0.0.0.0:80", "8080".

I read that updating the kernel solves the error. This was my case too.
You could easily check your kernel version with:
uname -a

Mine was 2.6.26. The new is 3.2.0-2-686-pae. Somewhere between this two versions, there is a change with new way of opening a socket. The new apache uses it, and in the old kernel it is not supported.

Here are my instructions for updating the kernel for Debian Squeeze. But it is a risky operation, you could break your system (in this case you have to boot with the old stable kernel and to set it as default during start-up).
apt-cache search linux-image

This shows the available kernels. For me suitable is "linux-image-3.2.0-2-686-pae ".

apt-get install linux-image-3.2.0-2-686-pae

This copies the new kernel on your system.
update-grub

This registers the new kernel in boot loader.

If you have changed the default boot kernel (as me), you have some additional steps.
You have to check the new value and possibly correct it. The lists with kernels is in file /boot/grub/menu.lst
For example:
title           Debian GNU/Linux, kernel 3.2.0-2-686-pae
root            (hd0,0)
kernel          /boot/vmlinuz-3.2.0-2-686-pae root=/dev/md0 ro quiet
initrd          /boot/initrd.img-3.2.0-2-686-pae

title           Debian GNU/Linux, kernel 3.2.0-2-686-pae (single-user mode)
root            (hd0,0)
kernel          /boot/vmlinuz-3.2.0-2-686-pae root=/dev/md0 ro single
initrd          /boot/initrd.img-3.2.0-2-686-pae

title           Debian GNU/Linux, kernel 3.0.0-1-686-pae
root            (hd0,0)
kernel          /boot/vmlinuz-3.0.0-1-686-pae root=/dev/md0 ro quiet
initrd          /boot/initrd.img-3.0.0-1-686-pae

title           Debian GNU/Linux, kernel 3.0.0-1-686-pae (single-user mode)
root            (hd0,0)   
kernel          /boot/vmlinuz-3.0.0-1-686-pae root=/dev/md0 ro single
initrd          /boot/initrd.img-3.0.0-1-686-pae

title           Debian GNU/Linux, kernel 2.6.26-2-686
root            (hd0,0)
kernel          /boot/vmlinuz-2.6.26-2-686 root=/dev/md0 ro quiet
initrd          /boot/initrd.img-2.6.26-2-686

title           Debian GNU/Linux, kernel 2.6.26-2-686 (single-user mode)
root            (hd0,0)
kernel          /boot/vmlinuz-2.6.26-2-686 root=/dev/md0 ro single
initrd          /boot/initrd.img-2.6.26-2-686


update-grub command have added in the first two section.

The important option in the file is default. Its value starts from 0, not from 1, take care of it. For me it was 2. Before this was referred to section "2.6.26-2-686", but after update-grub it is "3.0.0-1-686-pae" - the kernel which is not working for me. So I changed the default to 0, referred to "3.2.0-2-686-pae", the new kernel, and rebooted the system.

After reboot, you have to be able to start apache without errors.

No comments:

Post a Comment