Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I found my vps nginx error log like this

2013/04/06 03:28:04 [alert] 8557#0: mmap(MAP_ANON|MAP_SHARED, 5242880000) failed (12: Cannot allocate memory)
2013/04/06 04:05:30 [alert] 10299#0: mmap(MAP_ANON|MAP_SHARED, 5242880000) failed (12: Cannot allocate memory)
2013/04/06 04:05:58 [alert] 10786#0: mmap(MAP_ANON|MAP_SHARED, 5242880000) failed (12: Cannot allocate memory)

What is the caused? ram about 16GB


share|improve this question
what's your php max memory setting in php.ini? – Marcel Apr 5 '13 at 21:59
I have the same issue, but my server is only 256MB, and it worked for couple of years before last upgrade. I reduced the php-fpm memory to 64Mb, still have the same error in nginx. Any other idea? – Kostanos Jul 1 '14 at 3:08

First, I advise you to provide more information about free memory you have and nginx version.

It seems you do not have additional ~5G memory on your server.

Try to decrease shared memory size in your nginx config server (check proxy_cache_path in nginx)

share|improve this answer

Maybe it needs more shared memory? You might look at increasing the kernel.shmmax property in /etc/sysctl.conf It's probably not there by default but you can

cat /proc/sys/kernel/shmmax

to see what it is now.

share|improve this answer

My ram is 16gb but used by mysql, php-fpm and nginx about 14gb. This massaage appear when i restart nginx. Because nginx cache at /dev/shm about 5gb, nginx wan't restart if memory less then nginx cache size. this solved after restart php-fpm and free ram about 11gb. Thanks for your constribute

share|improve this answer
I did restart of php-fpm but nothing changed, any other idea? – Kostanos Jul 1 '14 at 3:02

I had the similar problem.

First check you shared memory settings.

echo $((`cat /proc/sys/kernel/shmmax` / 1024 / 1024))Mb

In my case I had only 32Mb.

If you want increase this memory (with your server's memory it could be a good idea), check this documentation

Second, check your nginx proxy settings - proxy_cache_path parameter. In my case it was inside of /etc/nginx/site-enabled/ but you may found it on any file inside /etc/nginx/ folder.

I had this line: fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=WORDPRESS:500m inactive=60m;, which required 500Mb! of shared memory.

So, change the keys_zone memory part to maximum of your shared memory. You may read more information about fastcgi_cache_path parameter here

Remember to restart nginx after.

Good Luck!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.