MHOSTMHOST

How to Run a Minecraft Server on a VPS: A Step-by-Step Guide

Your own Minecraft server on a VPS runs around the clock, doesn't depend on your computer or router, and gives you full control: any plugins, mods, settings and a whitelist of players.

Compared to a home server, a VPS has a permanent public IP, a stable connection and no router port forwarding. Compared to ready-made game hosts, you get root access, no panel restrictions and the option to run a website, bot or Discord bot on the same server.

This guide installs Java Edition on Paper, the most popular optimized server with plugin support. Commands are for Ubuntu 22.04, 24.04 and 26.04.

What VPS Do You Need for a Minecraft Server

Minecraft is demanding on memory and single-core CPU speed: the main game loop runs on one thread. Guidelines for a Paper server:

  • Up to 5 players, a regular world and a few plugins — a VPS with 4 GB RAM, 3 GB allocated to the server.
  • 10–20 players with plugins — 8 GB RAM, about 6.5 GB for the server.
  • Large modpacks (Forge, NeoForge, Fabric) — 10–16 GB RAM or more.

Always leave 1–1.5 GB for the system: if Java takes all the memory, Linux starts killing the server process. The Paper team recommends 6–10 GB for the best garbage collector performance, but a small server for friends runs fine on less.

What else matters:

  • A high-clock CPU. Two fast cores beat eight slow ones.
  • NVMe storage. The world constantly loads from disk; a slow disk causes lag when exploring new areas.
  • A location close to your players. The closer the server, the lower the ping.
  • A prepared server: a sudo user, SSH key login and a firewall. If the server is new, complete the initial VPS setup first.

Current Minecraft Java Edition versions (26.x) require Java 25. The server won't start on an older Java.

Step 1. Install Java 25

The Paper team recommends Amazon Corretto, a free OpenJDK build with its own repository for Ubuntu and Debian. Install the required tools:

sudo apt update

sudo apt install -y ca-certificates apt-transport-https gnupg wget

Add the Corretto repository:

wget -O - https://apt.corretto.aws/corretto.key | sudo gpg --dearmor -o /usr/share/keyrings/corretto-keyring.gpg

echo "deb [signed-by=/usr/share/keyrings/corretto-keyring.gpg] https://apt.corretto.aws stable main" | sudo tee /etc/apt/sources.list.d/corretto.list

Install Java 25:

sudo apt update

sudo apt install -y java-25-amazon-corretto-jdk libxi6 libxtst6 libxrender1

Check the version:

java -version

The output should start with openjdk version "25. Don't install packages with -headless in the name: the Paper team warns they lack libraries the server needs.

Step 2. Create a User and Download Paper

Run the server as a separate user without admin rights. If someone breaks into the Minecraft server through a vulnerable plugin, they won't get access to the whole system.

sudo useradd -r -m -d /opt/minecraft -s /bin/bash minecraft

sudo -u minecraft mkdir -p /opt/minecraft/server /opt/minecraft/backups

Open the download page papermc.io/downloads/paper, pick your Minecraft version and copy the link to the latest build (right-click the download button → "Copy link address"). Download the file to the server:

cd /opt/minecraft/server

sudo -u minecraft wget -O paper.jar "BUILD_LINK"

The server version must match your players' game version. If your friends play a specific version, download Paper for that version.

Want a plain server without plugins? The official server.jar is on minecraft.net/download/server. The remaining steps are the same, just use server.jar instead of paper.jar.

Step 3. First Launch and server.properties

Start the server once so it creates its config files:

sudo -u minecraft java -Xms2G -Xmx2G -jar paper.jar --nogui

The server stops right away and asks you to accept the Minecraft EULA. Accept it:

sudo -u minecraft sed -i 's/eula=false/eula=true/' eula.txt

Generate a password for RCON, the remote console you'll use to manage the server. Save it; you'll need it later:

openssl rand -hex 16

Open the server settings:

sudo -u minecraft nano server.properties

Find and change these lines:

motd=My Minecraft Server

max-players=20

online-mode=true

white-list=true

enforce-whitelist=true

view-distance=8

simulation-distance=6

enable-rcon=true

rcon.port=25575

rcon.password=YOUR_RCON_PASSWORD

What they do:

  • online-mode=true checks Mojang accounts. With false, anyone can join under someone else's name, including an admin's.
  • white-list and enforce-whitelist let only whitelisted players join. For a server with friends, it's the best protection against random visitors and bots. For a public server, set them to false.
  • view-distance and simulation-distance set how far the world is rendered and processed, in chunks. These are the main settings that affect load.
  • enable-rcon turns on the remote console. We won't open the RCON port in the firewall, so it's only reachable from the server itself.

Step 4. Open the Port in the Firewall

Minecraft Java Edition uses port 25565/TCP. Open only that one:

sudo ufw allow 25565/tcp

sudo ufw status

Don't open the RCON port (25575). RCON can run any command on the server, so access must stay local.

If you want players on phones and consoles (Bedrock Edition) to join through the Geyser plugin, also open 19132/udp.

Step 5. Set Up Autostart and the Console

Start script. Create a file with optimized Java flags (Aikar's flags, recommended by the Paper team):

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

Paste these two lines. Replace 3G with the amount of memory for your server from the guidelines above:

#!/bin/bash

exec java -Xms3G -Xmx3G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar paper.jar --nogui

Make the script executable:

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

systemd service. It runs the server in the background, restarts it after a crash and starts it after a VPS reboot:

sudo nano /etc/systemd/system/minecraft.service

Paste the contents:

[Unit]

Description=Minecraft Server

After=network-online.target

Wants=network-online.target

[Service]

User=minecraft

WorkingDirectory=/opt/minecraft/server

ExecStart=/opt/minecraft/server/start.sh

Restart=on-failure

RestartSec=10

SuccessExitStatus=0 1 143

TimeoutStopSec=120

[Install]

WantedBy=multi-user.target

TimeoutStopSec=120 gives the server two minutes to save the world when stopping. Enable and start the service:

sudo systemctl daemon-reload

sudo systemctl enable --now minecraft

sudo systemctl status minecraft

Follow the server logs live: sudo journalctl -u minecraft -f.

Console via RCON. The server runs in the background, so you send commands with the mcrcon tool. Build it from source:

sudo apt install -y git build-essential

git clone https://github.com/Tiiffi/mcrcon.git /tmp/mcrcon

cd /tmp/mcrcon && make && sudo make install

Connect to the server console:

mcrcon -p YOUR_RCON_PASSWORD -t

Add yourself to the whitelist and grant operator rights:

whitelist add YOUR_NAME

op YOUR_NAME

Exit the console with Q or Ctrl+D. Now connect to the server in Minecraft using your VPS IP.

Step 6. Set Up Automatic World Backups

Griefers, a bad plugin or an update can ruin your world. A backup lets you roll back in minutes. The script below briefly turns off autosave, flushes the world to disk, archives the server folder and keeps copies for 7 days.

Create the script:

sudo -u minecraft nano /opt/minecraft/backup.sh

Paste the contents:

#!/bin/bash

export MCRCON_PASS="YOUR_RCON_PASSWORD"

mcrcon "save-off" "save-all flush"

tar -czf /opt/minecraft/backups/server-$(date +%F-%H%M).tar.gz -C /opt/minecraft server

mcrcon "save-on"

find /opt/minecraft/backups -name 'server-*.tar.gz' -mtime +7 -delete

Restrict access to the script, since it contains the password, and make it executable:

sudo chmod 700 /opt/minecraft/backup.sh

Schedule a daily run at 4:00 in the minecraft user's cron:

sudo crontab -u minecraft -e

0 4 * * * /opt/minecraft/backup.sh

Test the script manually with sudo -u minecraft /opt/minecraft/backup.sh, then ls -lh /opt/minecraft/backups. Also copy backups off the server: to S3 storage or another VPS.

How to Fix Server Lag

The key server metric is TPS (ticks per second). Normal is 20. When TPS drops below 18, players notice lag.

  • Lower the view distance. view-distance=8 and simulation-distance=6 in server.properties cut load significantly. On a weak VPS, use 6 and 4.
  • Pre-generate the world. Generating new chunks is the heaviest operation. The Chunky plugin builds the world in advance while nobody is playing. Console commands: chunky radius 3000 and chunky start.
  • Limit the world size. The worldborder set 6000 command stops players from flying off and endlessly generating new terrain.
  • Find the cause of lag. The spark plugin shows what's loading the server: spark tps prints TPS and load, and spark profiler builds a report on plugins and game mechanics.
  • Check memory. If the server crashes or the system kills it, lower -Xmx in start.sh or move to a plan with more RAM.

Download plugins from trusted sources: Hangar by the Paper team, Modrinth or SpigotMC. Put the plugin's .jar file into /opt/minecraft/server/plugins, then restart the server.

Protecting a Minecraft Server from DDoS and Bots

Game servers get attacked more often than websites: an upset player or a rival server can order a DDoS for a few dollars. Minecraft faces two kinds of threats.

Bot attacks. Hundreds of bots join at once, spam the chat and overload the server. Protection:

  • online-mode=true keeps out bots without a genuine account.
  • A whitelist for a private server.
  • Anti-bot plugins for public servers: they check new players and limit connections per IP.

Network DDoS attacks. Traffic floods the server's link and players get kicked. Plugins and the firewall inside the VPS can't help here: the link is saturated before traffic reaches the server. Protection has to come from outside:

  • A Minecraft proxy. Specialized services (such as TCPShield) hide the server's real IP and filter attacks. Free Cloudflare doesn't work for Minecraft, since it proxies only websites. For games, Cloudflare offers the paid Spectrum.

Don't publish your server's real IP if it's behind a proxy. Learn more in how to protect a VPS from DDoS attacks.

Common Errors

  • UnsupportedClassVersionError on startup. An old Java is installed. Minecraft 26.x needs Java 25; check with java -version.
  • Failed to bind to port. The server is already running, for example both manually and as a service. Keep only the systemd service.
  • Players get "Connection timed out". Port 25565 is closed. Check sudo ufw status and that the server is running: sudo systemctl status minecraft.
  • "You are not white-listed on this server". The player isn't whitelisted. Add them via RCON: whitelist add NAME.
  • The server suddenly shuts down and the logs say Killed. Linux killed the process for lack of memory. Lower -Xmx in start.sh, leaving the system 1–1.5 GB.
  • "Outdated server" or "Outdated client". The server version doesn't match the player's game version. Download Paper for the right version.

Checklist

FAQ

How many players can the server handle? It depends on plugins and activity, not just memory. On Paper, a 4 GB VPS comfortably handles 5–10 players, and 8 GB handles 20–40.

Can I use mods instead of plugins? Yes, but instead of Paper you need a Fabric, Forge or NeoForge server. The server and every player must have the same mods. Large modpacks need more memory.

How do I let players join from phones and consoles? Install the Geyser and Floodgate plugins: they let Bedrock Edition players join a Java server. Open port 19132/udp in the firewall.

How do I update the server to a new version? Back up, stop the server (sudo systemctl stop minecraft), replace paper.jar with the new build and start it again. Before updating, check that your plugins support the new version.

How do players connect by domain instead of IP? Create an A record, such as mc.example.com, pointing to your server's IP. Players can then type the domain instead of numbers.