# Empty reply from server

**URL:** <https://www.ruby-forum.com/t/empty-reply-from-server/206646>\
**Category:** NGINX\
**Created:** [May 6, 2011, 3:39pm UTC](https://www.ruby-forum.com/t/empty-reply-from-server/206646 "2011-05-06T15:39:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [May 6, 2011, 3:39pm UTC](https://www.ruby-forum.com/t/empty-reply-from-server/206646/1 "2011-05-06T15:39:38Z")

</div>

I’m setting up a new nginx environment and I’m having issues with 404’s.  
When I use curl to request a file that I know does not exist, nginx  
responds back with an empty reply… I would prefer a 404 not found  
with the correct http status code.

My config:

user nobody;  
worker\_processes 4;  
worker\_rlimit\_nofile 8192;  
events  
{  
worker\_connections 4096;  
}

http  
{  
include mime.types;  
default\_type text/plain;  
log\_format nn '$host $remote\_addr - $remote\_user [$time\_local]  
’ '“$request” $status $bytes\_sent ’ ‘“$http\_referer”  
“$http\_user\_agent”’;  
access\_log /opt/nginx/logs/access.log nn;  
error\_log /opt/nginx/logs/error.log;  
sendfile on;  
keepalive\_timeout 0;  
server  
{  
listen 80 default;  
root /opt/nginx/html/;  
index index.html index.htm index.php index.php5;  
include /opt/nginx/conf/location\_php.conf;  
}  
include /opt/nginx/conf/vhosts/\*.conf;  
}

The html root dir:

bash\> ls /opt/nginx/html/  
404.html 50x.html empty.html foobar index.html ping

The curl request:

curl -v [http://localhost/index.html2](http://localhost/index.html2)

- About to connect() to localhost port 80
- Trying 127.0.0.1… connected
- Connected to localhost (127.0.0.1) port 80

> GET /index.html2 HTTP/1.1  
> User-Agent: curl/7.15.5 (i386-redhat-linux-gnu) libcurl/7.15.5  
> OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5  
> Host: localhost  
> Accept: _/_

- Empty reply from server
- Connection #0 to host localhost left intact  
curl: (52) Empty reply from server
- Closing connection #0

The access log:  
localhost 127.0.0.1 - - [06/May/2011:09:35:17 -0400] “GET /index.html2  
HTTP/1.1” 200 0 “-” “curl/7.15.5 (i386-redhat-linux-gnu) libcurl/7.15.5  
OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5” - For some reason returning http  
status code 200?

The error log:  
2011/05/06 09:35:17 [error] 9879#0: \*9312 open()  
“/opt/nginx/html/index.html2” failed (2: No such file or directory),  
client: 127.0.0.1, server: , request: “GET /index.html2 HTTP/1.1”, host:  
“localhost”

I don’t understand what I’m doing wrong here… any thoughts?

Posted at Nginx Forum:

> **[empty reply from server](https://forum.nginx.org/read.php?2,196075,196075#msg-196075)**
>
> I'm setting up a new nginx environment and I'm having issues with 404's. When I use curl to request a file that I know does not exist, nginx responds back with an empty reply.... I would prefer a 404 not found with the correct http status code. My...

---

<div class="post-metadata">

**Author:** ![yellowbox9](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/7ba0ec/32.png) [@yellowbox9](https://www.ruby-forum.com/u/yellowbox9)\
**Post date:** [May 8, 2011, 12:35am UTC](https://www.ruby-forum.com/t/empty-reply-from-server/206646/2 "2011-05-08T00:35:07Z")

</div>

Hello!

On Fri, May 06, 2011 at 09:38:46AM -0400, yellowbox9 wrote:

> I’m setting up a new nginx environment and I’m having issues with 404’s.  
> When I use curl to request a file that I know does not exist, nginx  
> responds back with an empty reply… I would prefer a 404 not found  
> with the correct http status code.

You will be surprised, but nginx returns 404 in such cases by default.

> http  
> {  
> include mime.types;  
> default\_type text/plain;  
> log\_format nn '$host $remote\_addr - $remote\_user [$time\_local]  
> ’ '“$request” $status $bytes\_sent ’ ‘“$http\_referer”  
> “$http\_user\_agent”’;  
> access\_log /opt/nginx/logs/access.log nn;  
> error\_log /opt/nginx/logs/error.log;

It’s good idea to specify error\_log at _global_ level, not http.  
When defined at http level it will be only used for http-related  
problems, but not for generic problems.

E.g. with your config information about abnormally terminated  
workers won’t reach error\_log you specified, but will go to  
compiled-in default error log instead.

> ```
> sendfile on;
> keepalive_timeout 0;
> server
> {
> listen 80 default;
> root /opt/nginx/html/;
> index index.html index.htm index.php index.php5;
> include /opt/nginx/conf/location_php.conf;
> 
> ```

Please show contents of the included file.

> ```
> }
> include /opt/nginx/conf/vhosts/*.conf;
> 
> ```

And please show contents of these includes, if there are any.

> - About to connect() to localhost port 80  
> curl: (52) Empty reply from server  
> “/opt/nginx/html/index.html2” failed (2: No such file or directory),  
> client: 127.0.0.1, server: , request: “GET /index.html2 HTTP/1.1”, host:  
> “localhost”
> 
> I don’t understand what I’m doing wrong here… any thoughts?

Empty response indicate either “return 444” somewhere in your  
config or some error occured (and it’s impossible to return error  
to the client).

Status 200 in your access log indicate that your set some  
error\_page processing somewhere in your config.

It’s impossible to say anything for sure from information you  
provided (basically there is no full error log, and no full  
config), but I assume you did something like

```
error_page 404 =200 /error;

location /error {
    return 444;
}

```

which will lead to the exactly the same results as you described.

Maxim D.

---

<div class="post-metadata">

**Author:** ![yellowbox9](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/7ba0ec/32.png) [@yellowbox9](https://www.ruby-forum.com/u/yellowbox9)\
**Post date:** [May 9, 2011, 7:18pm UTC](https://www.ruby-forum.com/t/empty-reply-from-server/206646/3 "2011-05-09T19:18:55Z")

</div>

Nothing is in the vhosts dir… and I’m not doing anything like :

error\_page 404 =200 /error;

location /error {  
return 444;  
}

Not

Posted at Nginx Forum:

> **[Re: empty reply from server](https://forum.nginx.org/read.php?2,196075,196789#msg-196789)**
>
> I'm setting up a new nginx environment and I'm having issues with 404's. When I use curl to request a file that I know does not exist, nginx responds back with an empty reply.... I would prefer a 404 not found with the correct http status code. My...

---

<div class="post-metadata">

**Author:** ![yellowbox9](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/7ba0ec/32.png) [@yellowbox9](https://www.ruby-forum.com/u/yellowbox9)\
**Post date:** [May 16, 2011, 6:40am UTC](https://www.ruby-forum.com/t/empty-reply-from-server/206646/4 "2011-05-16T06:40:59Z")

</div>

how about this file?

```
             include /opt/nginx/conf/location_php.conf;
```
