SSH and - bash: fork: Unable to allocate VPS Ubuntu memory

I host my Rails application on Ubuntu 12.04 VPS, Nginx + Unicorn, after deployment everything is fine, but a few hours later, when I ssh for VPS, I get this message

-bash: fork: Cannot allocate memory -bash: wait_for: No record of process 4201 -bash: wait_for: No record of process 4201 

If I run any command, it will simply return

 -bash: fork: Cannot allocate memory. 
+7
source share
2 answers

You seem to have run out of memory. Many VPS servers are configured without a swap, so when you run out of memory, it will kill things in a seemingly random way.

The easiest way to fix this is to get more memory for your VPS, which will probably cost more money. The next best way (besides running fewer files and optimizing memory for the whole run) would be to add a swap partition or swap file.

For a 1GB swap file (with root privileges):

 dd if=/dev/zero of=/swapfile bs=1M count=1024 mkswap /swapfile swapon /swapfile 

Be sure to add it to / etc / fstab as:

 /swapfile none swap defaults 0 0 

This will return it after reboot.

+10
source

To exit this state without rebooting, you can start the OOM killer manually as follows:

 echo 1 > /proc/sys/kernel/sysrq echo f > /proc/sysrq-trigger echo 0 > /proc/sys/kernel/sysrq 

By doing this, you can check dmesg to find the process responsible for capturing all of your memory.

0
source

Source: https://habr.com/ru/post/978310/


All Articles