“Unable to fork: Cannot allocate memory”
root@server]# vzctl enter [container ID]
We get the error like “Unable to fork: Cannot allocate memory”

Some times we get error while entering in to the VPS server vzctl enter [CT ID], We get the errorlike “Unable to fork: Cannot allocate memory”

This error is basically received in case of the VPS is running out of the resources. In this case even rebooting the VPS may fix it on temporary basis and not permanently. To sort this issue we can increase the kmemsize & privvmpages values for the VPS in order to solve the issue.

The size of unswappable memory allocated by the operating system kernel. It includes all the kernel internal data structures associated with the Container processes, except the network buffers.

This parameter allows controlling the amount of memory allocated by applications.

For eliminating the error just follow the below mentioned steps:

check the container id in cat /proc/user_beancounters by firing the command

root@server]# cat /proc/user_beancounters | grep container ID

Then you will be able to see Container ID: kmemsize 2505478 2538648 11055923 11377049 0

So the memory is consumed totally.now,

root@server]# vzctl set container ID –k memsize 12752512:12752512 –save

Now restart the container vzctl restart container ID

OR I my case I have just restarted the VPS container

That’s it!! Now try to enter to the VPS container and you will not receive the error.