How to Fix 404 Nginx Errors After Upgrading Ubuntu Server

One of the most common Web server combinations today features the Nginx Web server software implementation running on Ubuntu Server edition. This system is extremely efficient and easy to keep updated, since both packages continue to receive regular updates. System administrators generally install updates through the apt package manager, because Ubuntu Server has no graphical interface by default.

Ubuntu Server upgrades can sometimes generate unusual errors, and this lack of a graphical user interface can make it difficult for beginners to troubleshoot them. A few simple commands might be all it takes to fix 404 Nginx errors after an Ubuntu upgrade.

Method 1: Fixing Missing Nginx Error Pages

If a site is hosted on AWS, a private server or any other server configuration in a LEMP stack, it might go down randomly after an Ubuntu Server upgrade. Attempt to access the site from a Web browser, perhaps on another machine. Assuming it returns a 404 error, head to the Ubuntu Server CLI and run the command tail -f   to view all the most recent errors.

Should the log contain an error such as:

Your system is suffering from a missing error page. You might also see 40x.html in this line, though that’s relatively uncommon if your site is down and you’re getting 404 errors in exchange. Use the command ls   to see if there’s anything there. If not, then you’ll need to create the HTML code for a page for 50X errors.

Keep in mind that using the default  directory structure is often a problem with package managers, which can overwrite whatever gets stored there. You can change the docroot line in the Nginx configuration to prevent this sort of problem if you’re permitted to create a custom directory structure.

Method 2: Making PHP Find the Right Socket

You might also find an error that reads something like this in the

This means you have PHP7.0 running, but it isn’t running where it should be. The version number might be different depending on how you have PHP configured. Default installations will run from  or , but if you have this error that’s more than likely not the case.

Run the commands  and then find -name ‘php*fpm.sock’ to see if there’s a socket running somewhere on your system.

Assuming you received positive output, then you need to update your Nginx configuration to show the correct place in   the socket should be running. Naturally, /directoryPath would be replaced with the correct path. The line php/php7.0-fpm.sock should update the configuration if you’re using a socket file.

Users of the older TCP sockets that don’t use socket files can check if a PHP socket is currently listening to port 9000 by running sudo netstat -tulpn | grep 9000  off the command line. If this is the case, then open up your fastcgi_pass in nano, vi or another text editor and change out the unix:… line to instead use to update the socket.

Should none of this work, then make sure that php7.0-fpm or whatever version number you’re using is running with the command sudo systemctl restart php7.0-fpm, followed by repeating the above process.

Keep in mind that in most circumstances the listen entry in  and the value in need to be the same. You might try  for newer configurations, or for old style ones.

Kevin Arrows
Kevin is a dynamic and self-motivated information technology professional, with a Thorough knowledge of all facets pertaining to network infrastructure design, implementation and administration. Superior record of delivering simultaneous large-scale mission critical projects on time and under budget.

Expert Tip

How to Fix 404 Nginx Errors After Upgrading Ubuntu Server

If the issue is with your Computer or a Laptop you should try using Restoro which can scan the repositories and replace corrupt and missing files. This works in most cases, where the issue is originated due to a system corruption. You can download Restoro by clicking the Download button below.

Download Now

I'm not interested