how to host Minecraft server on VPS Ubuntu
Learn how to run Paper Minecraft on Ubuntu 24.04 using Java 21 and systemd. We cover RAM sizing, opening port 25565, and how to avoid server crashes.
Wetin you dey build
Minecraft Java Edition server wey go dey stay up: Paper for Ubuntu 24.04, e dey run as dedicated minecraft user under systemd with Restart=on-failure, whitelist dey on, port 25565 open for both firewalls wey dey stand between your players and the JVM, and backups dey happen for way wey no go corrupt the world wey dem dey protect. The server itself na just one jar and one java command; everything wey dey make server wey your friends fit play for one year different from server wey go die first weekend na around that command, and na wetin this guide go teach you.
Two real warnings before you spend money. First, Minecraft dey chop memory plenty and e mostly dey use single-thread: 1 GB VPS no go fit run server wey person fit play; one fast core better pass four slow ones. Second, na Java Edition dis one. Bedrock players — consoles, phones, Windows Bedrock app — no fit join Java server; Bedrock need different server software for UDP 19132, or the Geyser plugin, wey no dey inside this guide.
You need fresh Ubuntu 24.04 KVM VPS wey get root or sudo, and about thirty minutes.
Sizing: wetin your friends server really need
RAM na the number wey matter, and the real figures low pass wetin dem dey talk for modpack forums:
- 2 GB fit run vanilla for 2–5 players with small view distance. E go work, but no extra space.
- 4 GB na the correct size for friends-server: around ten players wey dey play at the same time for Paper with some plugins, and e go get enough space for OS.
- 8 GB and up na for modpack and 20-plus players; for this level, you must look for single-core CPU speed too, because the main game loop dey run for one thread.
The world go also dey take space for disk as players dey explore — survival world wey many people don travel for e reach several gigabytes — so make sure you leave space for the world and its backups.
Vanilla or Paper? Paper na replacement for the official jar: same worlds, same clients, no need for client-side mods. E rewrite the slowest server paths — chunk loading, entity ticking, hoppers — and e add plugin API. The only reason to run vanilla na if you need exact vanilla mechanics for technical redstone farms wey Paper's optimisations fit change; for everybody else, Paper dey give more players per gigabyte. Everything wey dey below work for both.
Step 1: install Java 21
Minecraft 1.20.5 and all version wey follow am (all of 1.21.x) need Java 21. Ubuntu 24.04 get am for default repos, and the headless build no carry desktop libraries wey server no go ever use:
sudo apt update && sudo apt install -y openjdk-21-jre-headless
java -versionCorrect result: the first line must show openjdk version "21.0.x". If e show 17 or 11, another JRE dey fight am; fix am with sudo update-alternatives --config java and pick the one wey get java-21.
If you skip this check, you go see the number one Minecraft server error wey people dey search for for Google later. If you use Java 17, the server jar go crash immediately with:
Error: LinkageError occurred while loading main class net.minecraft.bundler.Main
java.lang.UnsupportedClassVersionError: net/minecraft/bundler/Main has been
compiled by a more recent version of the Java Runtime (class file version 65.0),
this version of the Java Runtime only recognizes class file versions up to 61.0The numbers dey explain the mismatch: class file version 65.0 na Java 21, 61.0 na Java 17, 60.0 na Java 16. No matter which pair you see, the fix na the same — install the newer JRE and run update-alternatives again.
Step 2: use dedicated user, no be root
Server dey run plugin code and parse network input from any person wey fit reach the port. If something go wrong, if you dey run as root, person go take over your VPS; if you dey run as minecraft, person go only take over one game world.
sudo adduser --system --group --home /opt/minecraft minecraft--system dey create account wey no get password and e no fit log in over SSH, with /opt/minecraft as its home and working directory. Every command wey touch the server from here on go run as this user.
Step 3: download the server jar from the official source
Only two places for you to get server jar: the official server download page for vanilla for minecraft.net, or the downloads page for Paper for papermc.io. Any third-party "download hubs" wey dey repackage server jars na malware channel wey don dey happen for long time — remember say server jar na arbitrary code wey you wan run 24/7 for box wey connect to internet.
Copy the download link for the current build from the official page (the URL dey change every time version and build dey change, so if you hardcode one here, e go rot), then:
cd /opt/minecraft
sudo -u minecraft wget -O server.jar 'PASTE-THE-COPIED-URL-HERE'Correct result: a server.jar of roughly 50 MB owned by minecraft, confirmed with ls -lh /opt/minecraft/server.jar.
Step 4: first run, the EULA, and op-ing yourself
Run the server interactively once before you touch systemd — the first run get two jobs wey only live console fit do well.
cd /opt/minecraft
sudo -u minecraft java -Xms1G -Xmx1G -jar server.jar noguiE go exit within seconds — Paper go spend small time apply its patches first — and the log go end with the line wey everybody dey see:
[ServerMain/INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info.No be error; na license gate. The run write eula.txt next to the jar. Read the linked EULA if you never see am, then flip the flag:
sudo -u minecraft sed -i 's/eula=false/eula=true/' /opt/minecraft/eula.txtRun the same java command again. This time e go generate the world — e go take one or two minutes for first boot — and e go settle for:
[Server thread/INFO]: Done (9.204s)! For help, type "help"You don get live console now. Use am for the second job: type op YourMinecraftName (your exact in-game username) and the server go write you into ops.json, so later — when no console dey attached — you fit run every admin command from inside the game. Then type stop to save and exit cleanly.
Step 5: server.properties, and why online-mode stays true
The first time you run am, e go write server.properties too. Most of the default settings dey fine; na these lines wey you need to check well-well:
online-mode=true
white-list=true
enforce-whitelist=true
view-distance=8
max-players=10
motd=A private server for people I actually knowonline-mode=true make the server check every username wey wan join against Mojang's session servers, to make sure say player really own the account. If you set am to false — wey dem dey call "cracked server" toggle — e mean say the server go just take wetin any client talk as truth: anyone fit join with any name, including yours, and since ops and whitelists dey use name, person fit pretend pass you and carry your operator permissions. The only real reason to set am to false na if you dey use authenticating proxy like Velocity, wey dey verify players itself. For normal server, make e stay true, no be debate.
view-distance na the biggest thing wey dey affect performance for the file — CPU and RAM cost go increase roughly with the square of this value. 8 na sensible default for VPS; 10 na vanilla default and e dey heavy more.
white-list=true plus enforce-whitelist=true dey lock the server so strangers no fit enter, wey the security section below talk say no be optional. Add players with /whitelist add TheirName inside game as an op.
Step 6: memory flags — why -Xms and -Xmx must be the same
JVM dey allocate heap memory between -Xms (starting size) and -Xmx (ceiling). If you dey run dedicated game server, set dem to the same value: the heap go reach the ceiling anyway, and to dey increase am step-by-step go just make garbage-collector work too much during play. For 4 GB VPS, the correct pair na:
/usr/bin/java -Xms3G -Xmx3G -jar server.jar nogui-Xmx no be total memory wey process dey use. JVM dey add off-heap overhead — thread stacks, JIT caches, direct buffers — wey reach roughly half a gigabyte or more, and Ubuntu itself need space. The rule of thumb: set -Xmx to at most VPS RAM minus 1 GB. If you pass that limit, you go face one of two problems. If the allocation fail from start, the server no go start and e go show:
Error: Could not reserve enough space for object heapThat one na direct error. The harder one na when the server start well but e go die after hours, when the heap full under load and kernel OOM killer go pick the biggest process for the box — the JVM. Nothing go show for server log; the proof dey for sudo dmesg | grep -i oom, wey go be line like Out of memory: Killed process 1234 (java). If your service dey restart "randomly", check there first, and reduce -Xmx.
For Paper, the project recommend Aikar's flags — na tuned G1GC set (-XX:+UseG1GC -XX:MaxGCPauseMillis=200 and other flags) wey dey make garbage-collection pauses smooth for big heaps. Copy the full line from the Paper documentation; for 2–4 GB heap, the improvement small but the flags no go cause wahala.
Step 7: a systemd unit with Restart=on-failure
If you start server manually, e go die when your SSH session close, and e no go start again after reboot. Write /etc/systemd/system/minecraft.service:
[Unit]
Description=Minecraft server (Paper)
After=network-online.target
Wants=network-online.target
[Service]
User=minecraft
Group=minecraft
WorkingDirectory=/opt/minecraft
ExecStart=/usr/bin/java -Xms3G -Xmx3G -jar server.jar nogui
Restart=on-failure
RestartSec=10
TimeoutStopSec=120
[Install]
WantedBy=multi-user.targetsudo systemctl daemon-reload
sudo systemctl enable --now minecraft
systemctl status minecraft
journalctl -u minecraft -fCorrect result: status go show active (running), and the journal — wey now dey carry server console output — go end for the Done line again.
Two things wey we choose inside that unit. Restart=on-failure go bring server back after crash, but e no go do am after clean stop, so maintenance go still dey possible. And TimeoutStopSec=120 important pass how e look: systemctl stop go send SIGTERM, Minecraft server go catch am and save every world before e exit, and for big world, that save go take time. Systemd default timeout fit send SIGKILL to JVM mid-save, and na so region files dey corrupt. Give am two minutes.
If the service dey flap and the journal show:
[Server thread/WARN]: **** FAILED TO BIND TO PORT!
[Server thread/WARN]: The exception was: io.netty.channel.unix.Errors$NativeIoException: bind(..) failed: Address already in use
[Server thread/WARN]: Perhaps a server is already running on that port?den something already dey hold 25565 — almost always na your earlier foreground run wey still dey alive for another SSH session. Find am with sudo ss -tlnp | grep 25565 and stop that copy; no ever run two servers for one port.
Step 8: open 25565 on both firewalls
Minecraft Java dey use TCP 25565 only (UDP na just optional query protocol, e dey off by default). For the VPS:
sudo ufw allow OpenSSH
sudo ufw allow 25565/tcp
sudo ufw enableNa that one be firewall one. Most VPS providers dey run second firewall for network level inside their control panel, and na that one people dey forget. Open TCP 25565 for there too. If you open only one of the two, the problem no dey easy to identify: the client go hang for "Connecting to the server..." and e go fail with Connection timed out: no further information — no refusal, no server error, nothing for journal, because the packets never reach. Verify from one machine wey dey outside the VPS with nc -vz your.server.ip 25565; succeeded means both firewalls open, hang means at least one no open.
While you dey inside ufw, the same box dey run SSH on public IP, and brute-force log noise go start within hours — set up Fail2ban for SSH on Ubuntu 24.04 before you forget.
Now connect: Multiplayer, Direct Connection, the server IP. Because you op'd yourself for step 4, in-game commands go work immediately — /whitelist add FriendName for each player, /gamemode creative if na that one be the plan.
Step 9: whitelist, because the internet dey find port 25565
To leave Minecraft server open for internet no be just theory: mass scanners dey sweep all IPv4 space for port 25565 continuously — hobbyist griefing projects don map hundreds of thousands of open servers like this — and if server no get whitelist, uninvited visitors go enter within days, sometimes hours. The whitelist from step 5 na the fix: online-mode=true dey prove identity, and the whitelist dey restrict entry to only the identities wey you choose. That pair na the whole security model, and e dey enough for friends server.
For console access without the game — like scripted backups or cron job — enable RCON for server.properties (enable-rcon=true, a strong rcon.password, port 25575) and build the small mcrcon client from its GitHub source for the VPS itself; e no dey Ubuntu's repos. No open 25575 for any firewall: RCON dey send password for cleartext, so make e stay loopback-only.
Step 10: backups wey no go spoil everything
One rule only: never copy world directory wen server dey write am. Region files dey rewrite continuously during play; if tar race with write, the archive go get half-written chunks. When you eventually restore am — the one time backup must work — the log go full with chunk-loading errors and terrain go get holes. Two ways dey help avoid this.
Stop-copy-start na the simple one, but you go lose one minute downtime:
sudo systemctl stop minecraft
sudo mkdir -p /opt/backups
sudo tar czf /opt/backups/world-$(date +%F-%H%M).tgz \
-C /opt/minecraft world world_nether world_the_end
sudo systemctl start minecraft(Paper split dimensions into world, world_nether, and world_the_end; vanilla server keep everything for world, so drop the other two for there.)
Save-off dey backup live: over RCON, use save-off (stop autosaver), then save-all flush (force everything to disk and wait), take the tar, then save-on. Na this version you go put for cron at 5 a.m.
Either way, backup wey dey stay for same VPS as server no be backup — scp or rclone the archives off the box, and keep more than one. Since you no go dey look console wen something break, put external check for port: Uptime Kuma for another box wey dey do TCP check against 25565 go tell you say server don down before your players do.
Plugins and upgrades
For Paper, plugin installation easy: just drop the jar file inside /opt/minecraft/plugins/ den, then restart the server — na so e dey end. Only download plugins from their official project pages (Hangar, Modrinth, SpigotMC). Na the same reason as the server jar: every plugin na arbitrary code wey dey run as the minecraft user.
To upgrade the server, follow these steps: stop the server, back up your files, replace server.jar with the new Minecraft version build, then start am. Two things make sure: World upgrades na one-way process — if you open one world with a newer version, you no go fit open am again with an older version, so make sure you get backups. Also, plugins dey often lag behind new Minecraft release by days or weeks, so check compatibility before you rush to update immediately.
If you prefer to manage all these things as a container — like version pinning, EULA acceptance, and memory flags as environment variables — the popular itzg/minecraft-server image dey run the same Paper server under Docker Compose on your VPS with the same firewall and backup rules.
FAQ
How much RAM Minecraft server need?
2 GB dey work for vanilla with 2–5 players; 4 GB dey fine for friends server with about ten players for Paper with small plugins; modpacks and 20-plus players need 8 GB or more. No matter how big your VPS be, set -Xmx to at most total RAM minus 1 GB — JVM dey use memory extra for heap, and if you pass that limit, you go get Error: Could not reserve enough space for object heap or silent OOM kill.
Why my friends no fit connect to my Minecraft server?
If client hang and e end for Connection timed out: no further information, e almost always mean firewall, and dem dey two: ufw for VPS and your provider network firewall for control panel. You must open TCP 25565 for both. Confirm say server dey listen with sudo ss -tlnp | grep 25565 for box, then test from outside with nc -vz your.server.ip 25565.
I suppose set online-mode=false for server.properties?
No. With online-mode=false the server skip Mojang authentication entirely, so anybody fit join with any username — even if na op name, dem go get their permissions — and skins and stable UUIDs go spoil. The only correct use na for behind proxy wey dey authenticate like Velocity wey dey verify players itself. For normal server, make e stay true.
Paper better pass vanilla Minecraft server?
For almost everybody, yes: Paper na drop-in jar wey dey load vanilla worlds, accept unmodified clients, tick entities and load chunks well well, and e add plugin ecosystem. The exception na technical-redstone communities wey need exact vanilla behaviour, because some Paper optimisations dey change am. For small VPS, Paper efficiency na free extra RAM.
How I fit back up Minecraft world without corrupt am?
No ever archive the world directory while server dey write for am — if copy race region-file write, e go produce corrupted chunks wey you go only see when you restore am. Either stop the server, tar the world directories, and start am again, or keep am live with save-off, save-all flush, tar, save-on over RCON. After that, move the archive commot for VPS.