A Minecraft server on a VPS stays online 24/7, has a fixed IP for friends to join, and doesn’t depend on someone’s home connection. This guide sets up a Java Edition server on Ubuntu or Debian, the right way: a dedicated user, systemd, sensible memory settings and automatic backups. (For Bedrock, see our Bedrock server guide.)
How much server do you need?
Minecraft’s main game loop is largely single-threaded, so per-core speed matters more than many cores.
| Players | RAM for the server | Notes |
|---|---|---|
| 1–5, vanilla | 2–3 GB | Small world |
| 5–20, Paper + a few plugins | 4–6 GB | Most friend groups |
| 20+ or modpacks | 8 GB+ | Modpacks are memory-hungry |
Leave ~1 GB for the operating system. See how much RAM a Minecraft server needs.
1. Install Java
Current Minecraft versions require Java 21:
sudo apt update
sudo apt install -y openjdk-21-jre-headless screen
java -version
If your distribution doesn’t package Java 21, use the Eclipse Temurin (Adoptium) repository. Older Minecraft versions need older Java; check the version you’re running.
2. Create a user and directory
Never run the server as root:
sudo adduser --system --group --home /opt/minecraft minecraft
sudo -u minecraft mkdir -p /opt/minecraft/server
cd /opt/minecraft/server
3. Download the server
Paper (recommended): a high-performance fork of the vanilla server that supports Bukkit/Spigot plugins. Download the latest build for your Minecraft version from papermc.io:
sudo -u minecraft wget -O server.jar "https://…/paper-<version>-<build>.jar"
Vanilla: download server.jar from the official Minecraft website.
4. First start and EULA
sudo -u minecraft java -Xms2G -Xmx2G -jar server.jar --nogui
It stops and asks you to accept the EULA:
sudo -u minecraft sed -i 's/eula=false/eula=true/' eula.txt
5. Configure server.properties
Key settings:
motd=My VPS Minecraft Server
max-players=20
difficulty=normal
view-distance=8
simulation-distance=6
white-list=true
enforce-whitelist=true
online-mode=true
view-distanceandsimulation-distanceaffect CPU and RAM more than anything else; lower them if the server lags.online-mode=trueverifies players with Mojang/Microsoft accounts — keep it on.- A whitelist keeps strangers out (public servers get griefers and bots quickly).
6. Run it as a systemd service
/etc/systemd/system/minecraft.service:
[Unit]
Description=Minecraft Server
After=network.target
[Service]
User=minecraft
WorkingDirectory=/opt/minecraft/server
ExecStart=/usr/bin/java -Xms4G -Xmx4G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -jar server.jar --nogui
Restart=on-failure
RestartSec=10
SuccessExitStatus=0 1 143
[Install]
WantedBy=multi-user.target
The G1GC flags are based on the widely used “Aikar’s flags” for smoother garbage collection. Set -Xms and -Xmx to the same value, within your RAM budget.
sudo systemctl daemon-reload
sudo systemctl enable --now minecraft
journalctl -u minecraft -f
To send console commands (like whitelist add), enable RCON in server.properties (enable-rcon=true, a strong rcon.password, port bound to localhost via firewall) and use a client like mcrcon, or run the server inside screen/tmux instead of systemd.
7. Firewall
sudo ufw allow 25565/tcp
Keep the RCON port (25575) closed to the internet.
8. Whitelist and operators
Via RCON or console:
whitelist add PlayerName
op YourName
9. Backups
Worlds are irreplaceable. A simple nightly backup (the save-off/save-all dance avoids copying files mid-write):
#!/bin/bash
set -euo pipefail
cd /opt/minecraft/server
mcrcon -p "$RCON_PASS" "save-off" "save-all flush"
sleep 5
tar czf "/opt/minecraft/backups/world-$(date +%F_%H%M).tar.gz" world world_nether world_the_end
mcrcon -p "$RCON_PASS" "save-on"
find /opt/minecraft/backups -name 'world-*.tar.gz' -mtime +7 -delete
Schedule it with cron and copy backups off the server.
10. Performance tips
- Pre-generate the world with a plugin like Chunky so exploration doesn’t cause lag spikes.
- Use Paper’s configuration (entity limits, redstone settings) to tame lag machines.
- Monitor with the spark plugin to find what’s using CPU.
- Choose a location close to your players — latency matters in games.
Easier management
For several servers or a web panel, see Pterodactyl, AMP or LinuxGSM.
Our game server VPS options give you KVM virtualization, SSD storage and locations in the USA, Hong Kong and Tokyo, close to your players.