NGINX Install fails on Ubuntu 22.04 Jammy-Jellyfish if IPv6 is disabled


Just a quick post to save others some hunting. If you have grub set to disable IP v6 with the command ipv6.disable=1 you will see your Nginx install fail with the fairly opaque messages below.

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
nginx is already the newest version (1.18.0-6ubuntu14.4).
0 upgraded, 0 newly installed, 0 to remove and 127 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up nginx-core (1.18.0-6ubuntu14.4) ...
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details.
invoke-rc.d: initscript nginx, action "start" failed.
× nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2023-12-08 14:14:56 UTC; 40ms ago
Docs: man:nginx(8)
Process: 119649 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
CPU: 40ms

Dec 08 14:14:55 lancelot systemd[1]: Starting A high performance web server and a reverse proxy server...
Dec 08 14:14:56 lancelot nginx[119649]: nginx: [emerg] socket() [::]:80 failed (97: Unknown error)
Dec 08 14:14:56 lancelot nginx[119649]: nginx: configuration file /etc/nginx/nginx.conf test failed
Dec 08 14:14:56 lancelot systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
Dec 08 14:14:56 lancelot systemd[1]: nginx.service: Failed with result 'exit-code'.
Dec 08 14:14:56 lancelot systemd[1]: Failed to start A high performance web server and a reverse proxy server.
dpkg: error processing package nginx-core (--configure):
installed nginx-core package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of nginx:
nginx depends on nginx-core (<< 1.18.0-6ubuntu14.4.1~) | nginx-full (<< 1.18.0-6ubuntu14.4.1~) | nginx-light (<< 1.18.0-6ubuntu14.4.1~) | nginx-extras (<< 1.18.0-6ubuntu14.4.1~); however:
Package nginx-core is not configured yet.
Package nginx-full is not installed.
Package nginx-light is not installed.
Package nginx-extras is not installed.
nginx depends on nginx-core (>= 1.18.0-6ubuntu14.4) | nginx-full (>= 1.18.0-6ubuntu14.4) | nginx-light (>= 1.18.0-6ubuntu14.4) | nginx-extras (>= 1.18.0-6ubuntu14.4); however:
Package nginx-core is not configured yet.
Package nginx-full is not installed.
Package nginx-light is not installed.
Package nginx-extras is not installed.

dpkg: error processing package nginx (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Errors were encountered while processing:
nginx-core
nginx
needrestart is being skipped since dpkg has failed

The fix is to:

Edit the default nginx site

  1. run sudo vi /etc/nginx/sites-available/default to open the file (feel free to use nano or emacs in place of vi if preferred.
  2. Find the line that reads listen [::]:80 default_server;
  3. Add a # to the start of the line so it shows #listen [::]:80 default_server;
  4. Save the file. If using vi:
    • hit ESC
    • type :wq and hit enter to save and quit

Rerun the nginx install

Run sudo apt install nginx

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.