Minecraft server with Paper
Paper on a VPS: its own user, a start script, a systemd service, firewall, console and updates.
7 min read
On this page
Applies to Debian 12/13, Ubuntu 22.04/24.04, AlmaLinux 9 and Rocky Linux 9. The result: a Paper server that starts at boot, comes back after a crash, and has a console you can reach at any time.
Requirements
- SSH access as root or a sudo user, see Connect via SSH.
- Java in the right version, see Install Java. Current Minecraft versions need Java 25, 1.20.5 to 1.21.x need Java 21.
- A few tools:
# Debian and Ubuntu
apt install -y curl jq tmux
# AlmaLinux and Rocky Linux
dnf install -y curl jq tmux1. Create a user
The server doesn't run as root but as its own user without a password:
useradd --system --create-home --home-dir /opt/minecraft --shell /bin/bash minecraft
mkdir -p /opt/minecraft/server
chown -R minecraft:minecraft /opt/minecraft2. Download Paper
You'll find the current version and its download link on the official page https://papermc.io/downloads/paper. Copy the link and download the file as minecraft:
sudo -u minecraft curl -fL -o /opt/minecraft/server/paper.jar "PASTE-THE-LINK-HERE"Or automatically through the official PaperMC API. Enter the Minecraft version you want; the script fetches the newest stable build:
VERSION="26.3"
URL=$(curl -fsS -H "User-Agent: my-server (admin@example.com)" \
"https://fill.papermc.io/v3/projects/paper/versions/$VERSION/builds" \
| jq -r 'map(select(.channel == "STABLE")) | .[0] | .downloads."server:default".url')
echo "$URL"
sudo -u minecraft curl -fL -o /opt/minecraft/server/paper.jar "$URL"PaperMC requires a User-Agent with contact details; put in yours. If echo prints null, there's no stable build for that version: check the version on the download page.
3. Accept the EULA
Minecraft only starts once you accept Mojang's EULA (https://aka.ms/MinecraftEULA). Read it, then:
echo "eula=true" | sudo -u minecraft tee /opt/minecraft/server/eula.txt4. Start script
-Xms and -Xmx set how much RAM Minecraft gets. Paper recommends setting both to the same value. Leave about 1 to 1.5 GB for the system:
| VPS RAM | -Xms / -Xmx |
|---|---|
| 2 GB | 1G (rather for tests or very small servers) |
| 4 GB | 3G |
| 8 GB | 6G |
| 16 GB | 14G |
Your plan's RAM is shown on the Overview under Specs.
sudo -u minecraft nano /opt/minecraft/server/start.sh#!/bin/sh
cd /opt/minecraft/server
exec java -Xms3G -Xmx3G \
-XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 \
-XX:+DisableExplicitGC -XX:+AlwaysPreTouch \
-jar paper.jar --noguiAdjust 3G to the table. Further memory tuning ("Aikar's flags") is described in the Paper documentation.
chmod +x /opt/minecraft/server/start.shStart it once by hand so Paper creates its files:
sudo -u minecraft /opt/minecraft/server/start.shAs soon as Done (…)! For help, type "help" appears, type stop. Now server.properties, the world and the plugins folder are in /opt/minecraft/server.
5. systemd service with a console
The service starts the server in a tmux session. It runs in the background, and you can still get into the console.
nano /etc/systemd/system/minecraft.service[Unit]
Description=Minecraft server (Paper)
After=network-online.target
Wants=network-online.target
[Service]
Type=forking
User=minecraft
WorkingDirectory=/opt/minecraft/server
ExecStart=/usr/bin/tmux new-session -d -s minecraft /opt/minecraft/server/start.sh
ExecStop=/usr/bin/tmux send-keys -t minecraft stop Enter
ExecStop=/bin/sh -c 'while /usr/bin/tmux has-session -t minecraft 2>/dev/null; do sleep 1; done'
TimeoutStopSec=120
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.targetExecStop sends stop to the console and waits until the world is saved. Restart=always restarts the server after a crash; even if you type stop in the console, it comes back after 10 seconds. To really stop it, use systemctl stop minecraft.
systemctl daemon-reload
systemctl enable --now minecraft6. Open port 25565
If a firewall is active (see Firewall):
# Debian and Ubuntu with ufw
ufw allow 25565/tcp
# AlmaLinux and Rocky Linux with firewalld
firewall-cmd --permanent --add-port=25565/tcp
firewall-cmd --reloadCheck that it runs
systemctl status minecraft
ss -tlnp | grep 25565active (running) and a line with :25565 mean the server is waiting for players. In the Minecraft client, go to Multiplayer → Add Server and enter your VPS's IP. On port 25565 you don't need to add a port.
Using the console
With tmux
sudo -u minecraft tmux attach -t minecraftYou see the live console and can type commands such as op yourname. To leave without stopping the server: Ctrl+B, release, then D.
If you prefer screen, it works the same way, with screen -dmS minecraft … in the service and screen -r minecraft to attach. Either way: pick just one of the two.
With RCON
RCON is a remote control for commands. In server.properties:
enable-rcon=true
rcon.port=25575
rcon.password=a-long-random-passwordDo not open port 25575 in the firewall. Connect with an RCON client on the server itself or through an SSH tunnel (ssh -L 25575:127.0.0.1:25575 root@203.0.113.10).
Logs
tail -f /opt/minecraft/server/logs/latest.log
journalctl -u minecraft -n 50Updates
-
Warn your players, then
systemctl stop minecraft. -
Make a backup:
bashtar -czf /opt/minecraft/backup-$(date +%F).tar.gz -C /opt/minecraft server -
Download the new
paper.jaras in step 2. When jumping to a new Minecraft version, first check that your plugins support it and whether you need a newer Java. -
systemctl start minecraftand look for errors in the log.
A world can't be moved back to an older Minecraft version. That's what the backup is for.
Common errors
| Problem | Cause and fix |
|---|---|
UnsupportedClassVersionError | Java too old for this Paper version. Install the matching Temurin, see Install Java. |
You need to agree to the EULA | eula.txt is missing or set to false. Step 3. |
Invalid maximum heap size / server is terminated, Killed in the log | More -Xmx than free RAM. Lower the value, possibly add swap as a buffer. |
| Players can't reach the server | Check ss -tlnp, the firewall rule for 25565/tcp and the IP in the client. |
Failed to bind to port | Is a second server already running? systemctl status minecraft; ss -tlnp shows who is using port 25565. |
systemctl stop takes long | Large worlds need time to save. After 120 seconds systemd gives up; raise TimeoutStopSec if needed. |
What next
- Secure your server and set up a firewall.
- Rather skip the maintenance? Game servers at CitexNode.
- Help: ticket.