Website shows 503 Service Unavailable: Unable to allocate 1168 bytes in shared memory

Created:

2016-11-16 13:21:13 UTC

Modified:

2017-08-16 16:27:43 UTC

0

Was this article helpful?


Have more questions?

Submit a request

Website shows 503 Service Unavailable: Unable to allocate 1168 bytes in shared memory

Applicable to:

  • Plesk 12.5 for Linux

Symptoms

  1. Website is configured with php-fpm handler and returns "503 Service Unavailable" error
  2. Errors like the following in domain's error_log :
    # tail -fn0 /var/www/vhosts/example.com/logs/error_log      
    [Fri May 13 21:59:19.413831 2016] [proxy:error] [pid 13377:tid 140562535446272] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /var/www/vhosts/system/example.com/php-fpm.sock (*) failed
    [Fri May 13 21:59:19.413892 2016] [proxy_fcgi:error] [pid 13377:tid 140562535446272] [client 10.10.10.10:44054] AH01079: failed to make connection to backend: httpd-UDS
  3. php5-fpm.service is down:

    # service php5-fpm status
    php5-fpm.service - The PHP FastCGI Process Manager
    Loaded: loaded (/lib/systemd/system/php5-fpm.service; enabled)
    Active: failed (Result: exit-code) since Fri 2016-05-13 22:05:30 EEST; 44s ago
    Process: 17263 ExecStart=/usr/sbin/php5-fpm --nodaemonize --fpm-config /etc/php5/fpm/php-fpm.conf (code=exited, status=78)
    Process: 17256 ExecStartPre=/usr/lib/php5/php5-fpm-checkconf (code=exited, status=0/SUCCESS)
    Main PID: 17263 (code=exited, status=78)

    May 13 22:05:30 server.hostname.com php5-fpm[17263]: [13-May-2016 22:05:30] ERROR: unable to allocate 1168 bytes in shared memory: Cannot allocate memory: Cannot...emory (12)
    May 13 22:05:30 server.hostname.com php5-fpm[17263]: [13-May-2016 22:05:30] ERROR: FPM initialization failed
    May 13 22:05:30 server.hostname.com systemd[1]: php5-fpm.service: main process exited, code=exited, status=78/n/a
    May 13 22:05:30 server.hostname.com systemd[1]: Failed to start The PHP FastCGI Process Manager.
    May 13 22:05:30 server.hostname.com systemd[1]: Unit php5-fpm.service entered failed state.
    Hint: Some lines were ellipsized, use -l to show in full.
  4. Error message unable to allocate 1168 bytes in shared memory in journalctl :
    # journalctl -xn
    -- Unit php5-fpm.service has begun starting up.
    May 13 22:07:35 server.hostname.com php5-fpm[25362]: [13-May-2016 22:07:35] ERROR: unable to allocate 1168 bytes in shared memory: Cannot allocate memory: Cannot allocate mem
    May 13 22:07:35 server.hostname.com php5-fpm[25362]: [13-May-2016 22:07:35] ERROR: FPM initialization failed
    May 13 22:07:35 server.hostname.com systemd[1]: php5-fpm.service: main process exited, code=exited, status=78/n/a
    May 13 22:07:35 server.hostname.com systemd[1]: Failed to start The PHP FastCGI Process Manager.

Cause

System cannot allocate required amount of memory.

Resolution

  1. Increase default value of vm.max_map_count parameter. Example how to do that is below:
    # sysctl -w vm.max_map_count=655300
    vm.max_map_count = 655300

    or

        # echo 655350 > /proc/sys/vm/max_map_count
  2. To change it permanently edit /etc/sysctl.conf and add following parameter with your value:
    vm.max_map_count=your_value
  3. Run sysctl -p to apply the changes in /etc/sysctl.conf immediately.

INFO

File /etc/sysctl.conf contains the maximum number of memory map areas a process may have. Memory map areas are used as a side-effect of calling malloc, directly by mmap and mprotect`, and also when loading shared libraries.

While most applications need less than a thousand maps, certain programs, particularly malloc debuggers, may consume lots of them, e.g. , up to one or two maps per allocation.

The default value is 65536.

Have more questions? Submit a request
Please sign in to leave a comment.