How to fix 404 not found nginx problem?

Posted April 21, 2016 529.4k views

I run Nginx on my wordpress site, but now all pages and categories, except homepage, suddenly appear “404 not found, Nginx”, the permalinks are correct and i don’t do anything before such problem occur. How can i troubleshoot and fix this problem?

Thank you!

  • Hi!

    In order to be able to help you, please post your nginx server block config (usually /etc/nginx/sites-enabled/file.conf) and the last few lines of Nginx’s error log:

    sudo tail -n 20 /var/log/nginx/error.log
  • i have same problem
    2017/06/07 06:18:44 [error] 21807#21807: *4 open() “/srv/roi/app/webroot/50x.html” failed (2: No such file or directory), client:, server: www., request: “GET / HTTP/1.0”, upstream: “fastcgi://unix:/var/run/php5-fpm.sock”

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.

Submit an Answer
9 answers

Change the line in the location block to:

try_files $uri $uri/ /index.php?q=$uri&$args;

and reload nginx

sudo systemctl reload nginx

All should be well :)

I did not understand what to do to solve.
Someone explain to me what is causing this problem?
Thank you!

I change my admin url to the ip and when I try using the link https://14.*******.-world-admin

It gives me white page with page not found, how do I fix this?

“How to fix 404 not found nginx problem? ” Easy to solve

Import :-
import { HashLocationStrategy, LocationStrategy } from ’@angular/common’;


providers: [
{provide: LocationStrategy, useClass: HashLocationStrategy}


Do you run a php-fpm interpreter or do you proxy-pass to a apache with php module running on your server? In first case please have all corresponding rewrite rules in your nginx config checked and static files locations to be set up to a right path. In the second case please check .htaccess file in your website root to be accessible by a webserver and to contain apropriate WP rewrite rules.

I have exactly the same, everything worked well, and I don’t know why, at one moment, all pages turned into 404 error. It works when I disabled permalinks, but I’ve tried everything..

Did you resolve your problem ? Thanks.

I still having this problem @kamaln7 help! my server block config etc/nginx/sites-enabled/kinbuweb is:

server {
    listen 80;
    listen [::]:80;

    root /var/www/kinbuweb/public;

    index index.php index.html index.htm index.nginx-debian.html;

    server_name kinbu.localhost;

    location / {
        try_files $uri $uri/ =404;

    location ~ \.php$ {
                include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    location ~ /\.ht {
        deny all;

And my sudo tail -n 20 /var/log/nginx/error.log from when I started having the problem:

2017/01/30 16:42:58 [notice] 2385#2385: signal process started
2017/01/30 16:46:45 [notice] 2468#2468: signal process started

im also getting an 404 nginx not found error

vi reverse_proxy.conf

server {
    listen 80;
    location / {
        proxy_pass http://myip;


sudo tail -n 20 /var/log/nginx/error.log

2019/05/04 13:21:36 [emerg] 4934#4934: no host in upstream "" in /etc/nginx/sites-enabled/reverse-proxy.conf:4
2019/05/05 10:08:30 [error] 4990#4990: *51 connect() failed (111: Connection refused) while connecting to upstream, client:, server: , request: "HEAD /robots.txt HTTP/1.0", upstream: "http://myip:80/robots.txt"

What may be the reason for this?

edited by MattIPv4