# Which 404 file does nginx calls?

**URL:** <https://www.ruby-forum.com/t/which-404-file-does-nginx-calls/237030>\
**Category:** NGINX\
**Created:** [October 20, 2013, 6:03pm UTC](https://www.ruby-forum.com/t/which-404-file-does-nginx-calls/237030 "2013-10-20T18:03:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [October 20, 2013, 6:03pm UTC](https://www.ruby-forum.com/t/which-404-file-does-nginx-calls/237030/1 "2013-10-20T18:03:44Z")

</div>

Somewhere something happened.  
I am not able to fix it.

error\_page 404 404.html  
During the test, i had this line in the site.conf file.

404.html had “File not found.”

Later i created a proper error page and changed the commands like this.

error\_page 404 404.php  
But nginx is still throwing “File not found.” but i have already deleted  
that 404.html file from server

When i check for error log, I am getting “FastCGI sent in stderr:  
“Primary  
script unknown” while reading response header from upstream”

How do i fix it?

Posted at Nginx Forum:

> **[Which 404 file does nginx calls?](https://forum.nginx.org/read.php?2,243869,243869#msg-243869)**
>
> Somewhere something happened. I am not able to fix it. error\_page 404 404.html During the test, i had this line in the site.conf file. 404.html had "File not found." Later i created a proper error page and changed the commands like

---

<div class="post-metadata">

**Author:** ![agriz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8edcca/32.png) [@agriz](https://www.ruby-forum.com/u/agriz)\
**Post date:** [October 20, 2013, 9:11pm UTC](https://www.ruby-forum.com/t/which-404-file-does-nginx-calls/237030/2 "2013-10-20T21:11:52Z")

</div>

server\_name .site.com;

root /var/www/site.com;  
error\_page 404 /404.php;  
access\_log /var/log/nginx/site.access.log;  
index index.html index.php;

if ($http\_host != “[www.site.com](http://www.site.com)”) {  
rewrite ^ http://www.site.com$request\_uri permanent;  
}

```
    location ~* \.php$ {

```

# try\_files $uri = 404;

```
        fastcgi_index index.php;
        fastcgi_pass 127.0.0.1:xxxx;
         fastcgi_buffer_size 128k;
         fastcgi_buffers 256 4k;
         fastcgi_busy_buffers_size 256k;
         fastcgi_temp_file_write_size 256k;
         fastcgi_read_timeout 240;

        include /etc/nginx/fastcgi_params;
        fastcgi_param SCRIPT_FILENAME

```

$document\_root$fastcgi\_script\_name;

# fastcgi\_param SCRIPT\_NAME $fastcgi\_script\_name;

```
    }

```

after adding error\_page 404 /404.php

it works for other files which are not php. It calls the error page.  
But if it is a php file, it shows “File not found.”

Posted at Nginx Forum:

> **[Re: Which 404 file does nginx calls?](https://forum.nginx.org/read.php?2,243869,243870#msg-243870)**
>
> Somewhere something happened. I am not able to fix it. error\_page 404 404.html During the test, i had this line in the site.conf file. 404.html had "File not found." Later i created a proper error page and changed the commands like

---

<div class="post-metadata">

**Author:** ![agriz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8edcca/32.png) [@agriz](https://www.ruby-forum.com/u/agriz)\
**Post date:** [October 20, 2013, 10:33pm UTC](https://www.ruby-forum.com/t/which-404-file-does-nginx-calls/237030/3 "2013-10-20T22:33:40Z")

</div>

On Sun, Oct 20, 2013 at 03:11:04PM -0400, agriz wrote:

> after adding error\_page 404 /404.php
> 
> it works for other files which are not php. It calls the error page.  
> But if it is a php file, it shows “File not found.”

[http://nginx.org/r/fastcgi\_intercept\_errors](http://nginx.org/r/fastcgi_intercept_errors)

## f

Francis D. removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![agriz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8edcca/32.png) [@agriz](https://www.ruby-forum.com/u/agriz)\
**Post date:** [October 20, 2013, 11:12pm UTC](https://www.ruby-forum.com/t/which-404-file-does-nginx-calls/237030/4 "2013-10-20T23:12:15Z")

</div>

Thanks a ton for you!

Posted at Nginx Forum:

> **[Re: Which 404 file does nginx calls?](https://forum.nginx.org/read.php?2,243869,243875#msg-243875)**
>
> Somewhere something happened. I am not able to fix it. error\_page 404 404.html During the test, i had this line in the site.conf file. 404.html had "File not found." Later i created a proper error page and changed the commands like
