How to configure 404s when using LEMP (Nginx) and WordPress

With my WordPress sites on DO VPS, when a 404 is reached the nginx 404 page is displayed rather than the WordPress one I would expect.

All the results in Google are quite old and relate to using permalinks and then the site 404ing. I am delighted to say that WordPress permalinks are working fine with my sites so its not connected to that.

Any suggestions?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

nano /usr/local/apps/nginx/etc/conf.d/webuzoVH.conf

server {
listen          80;
# The Document Root
root            /home/user/public_html;
error_log       /usr/local/apps/nginx/var/log/;
access_log      /usr/local/apps/nginx/var/log/ main;
include         /usr/local/apps/nginx/etc/conf.d/common;
try_files $uri $uri/ /index.php?q=$uri&$args;

Hi thanks both of you for your responses. @Pablo I didn’t want to have to explicitly set each 404 for my sites incase the theme changed. <br> <br>I realised I was explicitly requesting Nginx to handle the 404 pages rather than let WordPress handle them. I had the following set in my conf for each site in sites-enabled. <br> <br>fastcgi_intercept_errors on; <br> <br> <br> <br>Setting this to off (+ removing the redundant ‘location’ for the 404) resolved this issue for me. Thanks again both.

Did you follow a specific article on installing Wordpress? If so, can you please post it? <br> <br>Check nginx’s error logs, do you see anything? <br> <br><pre>tail /var/log/nginx/error.log</pre>