When trying to install nginxin Debian 9/stretch with the command:

sudo apt-get install nginx-full

The installation failed with the errors:

Setting up nginx-full (1.10.2-2) ...
[FAIL] Starting nginx: nginx failed!
invoke-rc.d: initscript nginx, action "start" failed.
dpkg: error processing package nginx-full (--configure):
  subprocess installed post-installation script returned error exit status 1

What is happening?


The error shows nginx is not able to start. Thus as the post-install scripts on Stretch are dependent on it starting for the installation to be successful, it shows that error.

Upon trying to boot it on further debug of the problem, it shows a more clear error:

nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol)

What it happens here, is that this server has IPv6 disabled, and the installation assumes this is a dual stack machine.

To correct this problem, edit /etc/nginx/sites-enabled/default and comment:

#listen [::]:80 default_server;

Now try to install it again, and it should work.

sudo apt-get install nginx-full

In alternative, as @Stephen Kitt pointed out:

sudo dpkg --configure --pending
  • 1
    After the first (failed) installation of nginx-full, once the configuration file is corrected it should also be possible to complete the installation by running dpkg --configure --pending, without re-installing the package. – Stephen Kitt Dec 7 '16 at 23:55
  • @StephenKitt Yeah, it makes sense, thanks – Rui F Ribeiro Dec 8 '16 at 0:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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