Just upgraded an old box to Ubuntu 10.04.2 LTS. Apache will not display images to a browser that are over about 2K. Small images seem to display fine. Static HTML and PHP continues to works fine as well.


apache2                                   2.2.14-5ubuntu8.4
apache2-mpm-prefork                       2.2.14-5ubuntu8.4
apache2-utils                             2.2.14-5ubuntu8.4
apache2.2-bin                             2.2.14-5ubuntu8.4
apache2.2-common                          2.2.14-5ubuntu8.4

here is an ngrep of an image that doesn't display fine in the browser:

T -> [AP]
  GET /path/path/logo.png HTTP/1.1..Host: 192.1
  68.0.54..Connection: keep-alive..Accept: application/xml,application/xhtml+
  ent: Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.13
   (KHTML, like Gecko) Chrome/9.0.597.98 Safari/534.13..Accept-Enco
  ding: gzip,deflate,sdch..Accept-Language: en-US,en;q=0.8..Accept-
  Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3....                      

T -> [A]
  HTTP/1.1 200 OK..Date: Wed, 09 Mar 2011 05:28:38 GMT..Server: Apa
  che/2.2.14 (Ubuntu)..Last-Modified: Tue, 05 Oct 2010 11:59:17 GMT
  ..ETag: "17b6f4-15fe-491dd63eb2f40"..Accept-Ranges: bytes..Conten
  t-Length: 5630..Keep-Alive: timeout=15, max=100..Connection: Keep
  -Alive..Content-Type: image/png.....PNG........IHDR...!...v......

This looks ok to me!

I have tried firefox and chrome, both display small images fine but when a large image is requested the browser prompts to download the file.

When the image file is saved to the local computer it is corrupt, it also takes a long time to save which makes me think the browser cannot see the content-length header sent from apache. Also when I look at the saved image file it includes the headers from apache, along with a bit of garbage at the top, like so:

vi logo.png:

^@^GÝ^]^@pbSHTTP/1.1 200 OK^M
Date: Wed, 09 Mar 2011 04:47:04 GMT^M
Server: Apache/2.2.14 (Ubuntu)^M
Last-Modified: Tue, 05 Oct 2010 11:59:17 GMT^M
ETag: "17b6ff-157c-491dd63eb2f40"^M
Accept-Ranges: bytes^M
Content-Length: 5500^M
Keep-Alive: timeout=15, max=94^M
Connection: Keep-Alive^M
Content-Type: image/png^M

Any ideas? It's driving me nuts.

There is nothing in apache error logs, and permissions are fine (because the image data is there, it's just somewhat corrupt).

There's no proxy or iptables on this ubuntu box either.

Thanks heaps!!


ps: just tried on IE from a different computer, same problem :( pps: rebooted server, no help.


Thanks for those wget ideas:

here's the output of wget from a remote machine (it couldn't read headers)

dbaker@fatburt:~$ wget http://foo/static/images2/nav_sprite.jpg
--2011-03-10 17:41:06--  http://foo/static/images2/nav_sprite.jpg
Resolving foo...
Connecting to foo||:80... connected.
HTTP request sent, awaiting response... 200 No headers, assuming HTTP/0.9
Length: unspecified
Saving to: `nav_sprite.jpg'

here's output of wget from the local server back onto itself (works fine)

wget http://foo/static/images2/nav_sprite.jpg
--2011-03-10 17:44:51--  http://foo/static/images2/nav_sprite.jpg
Resolving foo...
Connecting to foo||:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 79192 (77K) [image/jpeg]
Saving to: `nav_sprite.jpg'


thanks @uesp adding "EnableMMAP off" to /etc/apache2/httpd.conf and restarting apache fixed it, no idea why, but it did.


  • Smells a little like a wrong link MTU is being set. What about other big files that are not images?
    – Juliano
    Mar 9, 2011 at 13:48
  • Fixed the same problem on Fedora 29 with Apache 2.4.41, even my images were <1 Kb (png), thank you.
    – Arvy
    Apr 22, 2020 at 18:56

2 Answers 2


A few things you can try:

  • Try setting EnableSendfile off in the Apache config and restart (see Apache core documentation). Also try EnableMMAP off (see here for a issue very similar to yours).
  • When testing with a browser make sure the cache is cleared and/or force the image to be reloaded.
  • Test with a variety of file sizes and types. Is it just PNG files, all images, etc...? Narrowing in on what image size works and what doesn't might help in the end.
  • Try testing another web server (lighttpd, nginx, ...) and see if they exhibit the same behavior. This should tell you if the issue is Apache specific or something on the server/network itself.
  • Download files both remotely and locally and see if the response is any different.
  • 2
    Thanks heaps!! I tried EnableSendfile and EnableMMAP off, the "EnableMMAP off" on it's own fixed the problem. I'm reading more into that option to find out why ...
    – dtbaker
    Mar 10, 2011 at 7:50
  • Turning EnableMMAP off fixed my Ubuntu 20.04 apache from giving ERR_INVALID_HTTP_RESPONSE errors.
    – moodboom
    Feb 20, 2021 at 6:48

This issue is not browser based, you'll experience this issue no matter what browser you use. The file is corrupt because it isn't downloading completely. You can verify this by downloading it via scp or ftp transfer (which you should do to verify that it is in fact not corrupt).

Try a wget for the specific file. This will allow you to focus directly on downloading the file rather than dealing with any php or html issues that may have cropped up.

 wget http://your.website.com/path/to/image.png

Also, attempt this with a gif and jpg file so that you can be sure that maybe it's not just something with png and the upgrade.

Something else to look at would be to tail your logs:

 # tail -f /path/to/apache/logs

That way you can have a second terminal open and watch the results in real time as you attempt to access the images.

If you don't get anywhere with that (or hopefully you track the issue down to apache rather then with the images) uninstall and then reinstall apache.

  • Thanks for the wget idea, output added to original post.
    – dtbaker
    Mar 10, 2011 at 7:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .