Swap space is a portion of a hard disk drive (HDD) that is used for virtual memory and some vps dont have it by default

Adding Swap Space on Ubuntu

Adjust this to meet the needs of your own server (Size of swap space):

sudo fallocate -l 2G /swapfile

We can verify that the correct amount of space was reserved by typing:

ls -lh /swapfile

Make the file only accessible to root by typing:

sudo chmod 600 /swapfile

Verify the permissions change by typing:

ls -lh /swapfile

We can now mark the file as swap space by typing:

sudo mkswap /swapfile

After marking the file, we can enable the swap file, allowing our system to start utilizing it:

sudo swapon /swapfile

We can verify that the swap is available by typing:

sudo swapon --show

You can add the swap file information to the end of your /etc/fstab file (swap space will be loaded at system start) by typing:

echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab