Skip to content
CitexNode
All guides

Minecraft server with Paper

Paper on a VPS: its own user, a start script, a systemd service, firewall, console and updates.

7 min read

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:
bash
# Debian and Ubuntu
apt install -y curl jq tmux

# AlmaLinux and Rocky Linux
dnf install -y curl jq tmux

1. Create a user

The server doesn't run as root but as its own user without a password:

bash
useradd --system --create-home --home-dir /opt/minecraft --shell /bin/bash minecraft
mkdir -p /opt/minecraft/server
chown -R minecraft:minecraft /opt/minecraft

2. 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:

bash
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:

bash
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:

bash
echo "eula=true" | sudo -u minecraft tee /opt/minecraft/server/eula.txt

4. 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 GB1G (rather for tests or very small servers)
4 GB3G
8 GB6G
16 GB14G

Your plan's RAM is shown on the Overview under Specs.

bash
sudo -u minecraft nano /opt/minecraft/server/start.sh
bash
#!/bin/sh
cd /opt/minecraft/server
exec java -Xms3G -Xmx3G \
  -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 \
  -XX:+DisableExplicitGC -XX:+AlwaysPreTouch \
  -jar paper.jar --nogui

Adjust 3G to the table. Further memory tuning ("Aikar's flags") is described in the Paper documentation.

bash
chmod +x /opt/minecraft/server/start.sh

Start it once by hand so Paper creates its files:

bash
sudo -u minecraft /opt/minecraft/server/start.sh

As 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.

bash
nano /etc/systemd/system/minecraft.service
ini
[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.target

ExecStop 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.

bash
systemctl daemon-reload
systemctl enable --now minecraft

6. Open port 25565

If a firewall is active (see Firewall):

bash
# Debian and Ubuntu with ufw
ufw allow 25565/tcp

# AlmaLinux and Rocky Linux with firewalld
firewall-cmd --permanent --add-port=25565/tcp
firewall-cmd --reload

Check that it runs

bash
systemctl status minecraft
ss -tlnp | grep 25565

active (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

bash
sudo -u minecraft tmux attach -t minecraft

You 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:

ini
enable-rcon=true
rcon.port=25575
rcon.password=a-long-random-password

Do 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

bash
tail -f /opt/minecraft/server/logs/latest.log
journalctl -u minecraft -n 50

Updates

  1. Warn your players, then systemctl stop minecraft.

  2. Make a backup:

    bash
    tar -czf /opt/minecraft/backup-$(date +%F).tar.gz -C /opt/minecraft server
  3. Download the new paper.jar as in step 2. When jumping to a new Minecraft version, first check that your plugins support it and whether you need a newer Java.

  4. systemctl start minecraft and 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

ProblemCause and fix
UnsupportedClassVersionErrorJava too old for this Paper version. Install the matching Temurin, see Install Java.
You need to agree to the EULAeula.txt is missing or set to false. Step 3.
Invalid maximum heap size / server is terminated, Killed in the logMore -Xmx than free RAM. Lower the value, possibly add swap as a buffer.
Players can't reach the serverCheck ss -tlnp, the firewall rule for 25565/tcp and the IP in the client.
Failed to bind to portIs a second server already running? systemctl status minecraft; ss -tlnp shows who is using port 25565.
systemctl stop takes longLarge worlds need time to save. After 120 seconds systemd gives up; raise TimeoutStopSec if needed.

What next