WHM - Plesk - CWP

How to Host a Minecraft Server on a VPS

Running your own Minecraft server on a VPS gives you full control over the game version, mods, player slots, and uptime — without sharing resources with anyone else. This guide walks through the entire setup on a fresh Ubuntu 24.04 VPS, from first SSH login to a live, running server.


What You Need Before Starting

Before touching the terminal, make sure you have the following ready:

  • A VPS with at least 2 GB RAM (4 GB recommended for modded or multi-player setups)
  • Ubuntu 24.04 LTS installed (fresh, clean install preferred)
  • Root or sudo SSH access
  • A Minecraft version in mind — this guide uses the latest Paper 1.21

If you prefer not to manage the server yourself, providers like Papernodes offer managed Minecraft hosting with DDoS protection and one-click setup already handled for you.


Step 1: Update the System and Install Java

Minecraft requires Java. Paper 1.21 runs on Java 21, so we install that specifically.

sudo apt update && sudo apt upgrade -y
sudo apt install -y openjdk-21-jre-headless

Verify the installation:

java -version

You should see output similar to:

openjdk version "21.0.3" 2024-04-16
OpenJDK Runtime Environment (build 21.0.3+9-Ubuntu-1ubuntu1)
OpenJDK 64-Bit Server VM (build 21.0.3+9, mixed mode, sharing)

Step 2: Create a Dedicated User

Running Minecraft as root is a security risk. Create a separate system user for it:

sudo adduser --system --no-create-home --group minecraft

Then create the server directory and assign ownership:

sudo mkdir -p /opt/minecraft
sudo chown minecraft:minecraft /opt/minecraft

Step 3: Download PaperMC

PaperMC is a high-performance Minecraft server fork that reduces lag significantly compared to vanilla. Download the latest Paper 1.21 build:

cd /opt/minecraft
sudo -u minecraft wget -O paper.jar "https://fill-data.papermc.io/v1/objects/b51d49a5f62446b7cfc01e6c29e48e0ce6abd35a783134aace1047b839b178ef/paper-26.1.2-63.jar"

If the URL returns a 404, check papermc.io/downloads for the latest version string and update the command accordingly.


Step 4: Accept the EULA and Configure the Server

Run the jar once to generate the initial files, then accept Mojang’s EULA:

cd /opt/minecraft
sudo -u minecraft java -jar paper.jar --nogui

The server will stop automatically after generating files. Now accept the EULA:

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

Edit the main configuration file to set your preferences:

sudo -u minecraft nano /opt/minecraft/server.properties

Key settings to review:

# Maximum players allowed
max-players=20

# Server port (default is fine, must match firewall rule)
server-port=25565

# Gamemode: survival, creative, adventure, spectator
gamemode=survival

# Enable whitelist if you want invite-only access
white-list=false

# View distance affects RAM and CPU usage
view-distance=10

# Prevent non-authenticated players (disable only on private LANs)
online-mode=true

Step 5: Tune JVM Memory Flags

Default Java memory settings are poor for Minecraft. Use Aikar’s recommended flags for better garbage collection and performance:

java -Xms2G -Xmx2G \
  -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 \
  -jar paper.jar --nogui

Adjust -Xms and -Xmx based on your VPS RAM. For a 4 GB VPS, use -Xms3G -Xmx3G to leave some headroom for the OS.


Step 6: Create a systemd Service

Running the server manually means it dies when you close SSH. A systemd service keeps it running, restarts it on crash, and starts it automatically on reboot.

Create the service file:

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

Paste the following:

[Unit]
Description=Minecraft Paper Server
After=network.target

[Service]
User=minecraft
Group=minecraft
WorkingDirectory=/opt/minecraft
ExecStart=/usr/bin/java \
  -Xms2G -Xmx2G \
  -XX:+UseG1GC \
  -XX:+ParallelRefProcEnabled \
  -XX:MaxGCPauseMillis=200 \
  -XX:+UnlockExperimentalVMOptions \
  -XX:+DisableExplicitGC \
  -XX:+AlwaysPreTouch \
  -jar paper.jar --nogui
Restart=on-failure
RestartSec=5
StandardOutput=journal
StandardError=journal

[Install]
WantedBy=multi-user.target

Enable and start the service:

sudo systemctl daemon-reload
sudo systemctl enable minecraft
sudo systemctl start minecraft

Check that it is running:

sudo systemctl status minecraft

Step 7: Open the Firewall Port

If UFW is active on your VPS, allow Minecraft’s default port:

sudo ufw allow 25565/tcp
sudo ufw reload

If you are using a Plesk or cPanel-managed VPS, also check your provider’s control panel for an additional firewall layer — some hosts block non-standard ports by default at the network level.


Step 8: Connect and Test

Open Minecraft on your local machine, go to Multiplayer → Add Server, and enter your VPS IP address:

your.vps.ip.address:25565

If the port is the default 25565, you can also omit it:

your.vps.ip.address

The server should show as online within 30–60 seconds of the service starting.


Step 9: Monitor and Manage the Server Console

Since the server runs under systemd with no screen session, use journalctl to read live logs:

sudo journalctl -u minecraft -f

To send commands to the server console (like op username or stop), you need to attach to the process. The cleanest method is to use GNU Screen or tmux, but since we are using systemd, the simplest approach is to install mcrcon for remote console access.

Install mcrcon:

sudo apt install -y git build-essential
git clone https://github.com/Tiiffi/mcrcon.git /tmp/mcrcon
cd /tmp/mcrcon && make && sudo cp mcrcon /usr/local/bin/

Enable RCON in server.properties:

enable-rcon=true
rcon.port=25575
rcon.password=your_secure_password_here

Open the RCON port locally only (no need to expose it publicly):

sudo ufw allow from 127.0.0.1 to any port 25575

Restart the server and connect via mcrcon:

sudo systemctl restart minecraft
mcrcon -H 127.0.0.1 -P 25575 -p your_secure_password_here

You now have a live console where you can run any in-game command.


Step 10: Automate Backups

World data can be lost if the server crashes mid-write. Set up a simple daily backup using a cron job:

sudo crontab -u minecraft -e

Add this line to back up the world folder every day at 3:00 AM:

0 3 * * * tar -czf /opt/minecraft/backups/world-$(date +\%F).tar.gz /opt/minecraft/world

Create the backups directory first:

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

For remote backups, you can pipe the archive to an S3-compatible bucket using s3cmd or rclone — a worthwhile addition for any production server.


When Self-Hosting Gets Complicated

Managing a VPS Minecraft server works well if you are comfortable with Linux administration. However, as your player count grows, you will face additional challenges: DDoS attacks on the server IP, automated restarts after crashes, Bedrock/Java cross-play setup, and plugin conflict debugging.

At that point, purpose-built solutions like Papernodes Minecraft hosting handle the infrastructure layer for you — DDoS mitigation, automatic backups, and server management — so you can focus on running the game rather than the machine it runs on.


Quick Reference: Common Server Commands

Once connected via mcrcon or the console, these commands cover the most frequent admin tasks:

# Grant operator permissions to a player
op username

# Kick a player from the server
kick username reason

# Ban a player permanently
ban username

# Whitelist management
whitelist add username
whitelist remove username
whitelist on
whitelist off

# Change the time
time set day
time set night

# Check online players
list

# Graceful shutdown (saves world before stopping)
stop

Troubleshooting Common Issues

Server starts but players cannot connect
Check that port 25565 is open both in UFW and at the VPS provider’s network firewall. Run ss -tlnp | grep 25565 to confirm the process is actually listening.

Server crashes immediately on start
Run sudo journalctl -u minecraft --no-pager | tail -50 and look for OutOfMemoryError. If present, reduce the -Xmx value or upgrade your VPS plan.

High TPS lag despite low player count
Reduce view-distance in server.properties to 6 or 8. You can also install the Chunky plugin to pre-generate world chunks before players explore.

Java not found after installation
Run which java to find the binary path and update the ExecStart line in the systemd service file accordingly.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top