How to Fix: Nginx Failing to Start and Showing Dependency Errors

If Nginx won’t start for you after running apt dist-upgrade (or apt upgrade) and you’re seeing Nginx dependency errors similar to those below, this doc can help you get those dependencies resolved and Nginx started.

The following packages have unmet dependencies:
libnginx-mod-brotli : Depends: nginx-abi-1.24.0-1 but it is not installable
libnginx-mod-ssl-ct : Depends: nginx-abi-1.24.0-1 but it is not installable

Why is this happening?

Linux package management is a complex affair and from time to time dependencies get messed up and issues like this occur. Those who manage the packages make mistakes and bugs are introduced, just like code. It doesn’t happen often, but we seem to encounter it every 2-3 years. In this case, you can read all about it in the issue on the package maintainer’s Github.

Unfortunately for us, this dependency issue happened right around the time we launched the Brotli upgrade for SpinupWP AND this particular dependency issue often involves the libnginx-mod-brotli package. We don’t blame anyone for being absolutely certain that the SpinupWP Brotli upgrade caused the issue. But actually hundreds of our customers’ servers have been upgraded without this problem. Likely because they didn’t run apt dist-upgrade at the specific window of time where the dependency bug was present. Ironically, if you were a diligent sys admin and ran apt dist-upgrade often, you likely got the bug and had to deal with this issue. It’s also important to note that plenty of people not using SpinupWP are also reporting the issue.

We’ve fixed quite a few customer servers at this point and have some suggestions that you can try to prevent the issue or remedy the issue if you’re already experiencing it.

Prevention

You can check if you have the package that will cause the issue and perform some operations to prevent Nginx from breaking the next time you run apt dist-upgrade.

1. Check that Nginx is running and has no errors:

sudo systemctl status nginx

2. Run the following command:

sudo apt update

3. Review the packages that will be installed or upgraded by running the following command:

sudo apt list --upgradable

If the pending updates don’t include libnginx-mod-http-brotli-filter you can proceed with a running apt dist-upgrade. If you do see this package in the list, follow the instructions below.

4. Remove the installed Brotli package

sudo dpkg --remove libnginx-mod-brotli

5. Now run the following commands:

sudo apt --fix-broken install
sudo apt dist-upgrade

6. Check that Nginx is running:

sudo systemctl status nginx

7. Install the Brotli library again:

sudo apt install libnginx-mod-brotli

8. Now run the update:

sudo apt dist-upgrade

9. Check that Nginx is running:

sudo systemctl status nginx

Remediation

If you’ve already tried updating Ubuntu with apt dist-upgrade and Nginx is bro, try the following.

1. Backup your Nginx folder

sudo tar -czf ~/nginx-backup.tar.gz /etc/nginx/

2. Disable Brotli in the /etc/nginx/nginx.conf file by commenting out the following directive:

# include global/brotli.conf;

3. Now run:

sudo apt update && apt dist-upgrade

4. You might have to run the following command if the above command breaks, but APT will suggest this as well:

sudo apt --fix-broken install

Ubuntu might ask you to restart some services or use new or old configurations via update menus. Please always use the option to keep the old configurations.

5. Restart Nginx:

sudo systemctl restart nginx

6. Check that Nginx is running:

sudo systemctl status nginx

7. Install the Brotli library:

sudo apt install libnginx-mod-brotli

8. Now run the APT updates again to see if there are any other dependencies still missing:

sudo apt update && sudo apt dist-upgrade

9. Now enable loading Brotli in the /etc/nginx/nginx.conf file by removing the previously commented-out directive:

include global/brotli.conf;

10. Restart Nginx:

sudo systemctl restart nginx

11. Check that Nginx is running:

sudo systemctl status nginx

If Nginx is still not running and does not want to start, please contact SpinupWP support and we’ll help you get back online.

12. If everything is working, you should delete the backup we created in the first step:

sudo rm -f /home/spinupwp/nginx-backup.tar.gz

Hopefully these steps have helped you resolve the Nginx dependency issue and Nginx is back up and running.

You can enter your site URL at brotli.pro to check if Brotli compression is working on your site.