Everything you start in an SSH session dies when you close the session. To keep your server running, start it inside screen or tmux: they are "terminals that do not close", which you detach from and come back to.
With screen (the simplest)
apt install -y screen
# 1) Open a named session
screen -S minecraft
# 2) Inside it, start your server as usual
cd /home/minecraft/server && java -Xms4G -Xmx4G -jar paper.jar --nogui
- Leave without stopping it:
Ctrl + AthenD. - List your sessions:
screen -ls - Back to the console:
screen -r minecraft
With tmux
apt install -y tmux
tmux new -s rust
- Leave without stopping it:
Ctrl + BthenD. - List your sessions:
tmux ls - Back:
tmux attach -t rust
Common mistakes
- Pressing Ctrl + C inside the session stops the server, it does not take you out. To leave without stopping it, use the combination above.
- "There is no screen to be resumed": the session no longer exists, usually because the server closed or the VPS restarted.
It does not come back after a reboot
screen and tmux survive closing SSH, but not a VPS reboot. If you want the server to start by itself when the machine boots and come back up if it crashes, make it a service: how to create a systemd service.