Playing on a friend's laptop server works until that friend logs off, goes to bed or closes the lid. A Minecraft server on a VPS solves that problem: it stays online around the clock, has a fixed public IP address, and gives you full control over the world, the rules and who gets in.
This guide covers how to host a Minecraft server on a VPS running Ubuntu, using the official Java Edition server software from Mojang. By the end you will have a server that starts automatically, restarts if it crashes, and keeps regular backups of your world.
What you need before you start
- A Linux VPS running a current Ubuntu LTS release. These steps assume Ubuntu 22.04 or 24.04.
- Enough memory. Minecraft is RAM-hungry. A small vanilla server for a handful of friends can run on 2 GB of RAM allocated to Java, but plan on 4 GB or more of total server memory if you want room for more players, larger view distances or plugins. Modded packs often need much more.
- SSH access with a non-root sudo user. If you haven't hardened your server yet, start with our guides on setting up SSH keys and the first steps on a new Linux VPS.
- A Minecraft: Java Edition account for each player. Bedrock Edition (consoles, phones, Windows store version) uses different server software, covered briefly at the end.
CPU matters too. The main game loop in Minecraft is largely single-threaded, so a VPS with strong per-core performance usually feels smoother than one with many slow cores.
Step 1: Update the server and install Java
Log in over SSH and update your packages:
sudo apt update && sudo apt upgrade -y
Recent Minecraft releases need a recent Java runtime. Versions from 1.20.5 onward require Java 21, so install the headless OpenJDK 21 runtime (headless means no graphical components, which a server doesn't need):
sudo apt install -y openjdk-21-jre-headless
java -version
The second command should print a version starting with 21. If you plan to run an older Minecraft version, check which Java release it expects before you go further.
Step 2: Create a dedicated user and folder
Running a game server as root is a bad idea. If something goes wrong, you want the damage limited to one account. Create a system user just for Minecraft:
sudo adduser --system --group --home /opt/minecraft minecraft
Everything for the server will live in /opt/minecraft.
Step 3: Download the official server jar
Go to the official Minecraft server download page on minecraft.net, right-click the download link for the latest server.jar, and copy the link address. The URL changes with every release, so always copy it fresh rather than reusing an old one.
Then download it as the minecraft user:
cd /opt/minecraft
sudo -u minecraft wget -O server.jar "PASTE_THE_DOWNLOAD_LINK_HERE"
Step 4: Run it once and accept the EULA
Start the server one time so it generates its configuration files:
sudo -u minecraft java -Xms2G -Xmx2G -jar server.jar nogui
-Xms sets the starting memory for Java and -Xmx sets the maximum. Setting both to the same value avoids the heap resizing during play. Never give Java all of your VPS memory; leave at least 1 GB for the operating system.
The server will stop almost immediately and tell you to agree to the EULA. Open the file it created:
sudo -u minecraft nano /opt/minecraft/eula.txt
Change eula=false to eula=true, save and exit. By doing this you are agreeing to the Minecraft End User License Agreement, so it's worth reading it once.
Step 5: Configure server.properties
The main settings file is /opt/minecraft/server.properties. A few lines worth reviewing:
motd=is the message shown in the multiplayer server list.max-players=caps how many people can join at once.difficulty=can bepeaceful,easy,normalorhard.gamemode=sets the default mode, such assurvivalorcreative.view-distance=controls how many chunks are sent to each player. Lowering it is one of the easiest ways to reduce CPU and RAM use.white-list=truemeans only approved players can join. Strongly recommended for private servers.online-mode=truemakes the server verify accounts with Mojang. Leave this on; turning it off allows anyone to join with any username.
Step 6: Open the firewall port
Java Edition uses TCP port 25565 by default. If you use UFW:
sudo ufw allow 25565/tcp
sudo ufw status
Make sure SSH is also allowed before enabling UFW, or you can lock yourself out.
Step 7: Keep it running with systemd
Starting the server by hand works, but it dies when you close your SSH session. A systemd service fixes that and also starts the server after a reboot. Create the unit file:
sudo nano /etc/systemd/system/minecraft.service
Paste this in, adjusting the memory values to suit your VPS:
[Unit]
Description=Minecraft Java Server
After=network.target
[Service]
User=minecraft
Group=minecraft
WorkingDirectory=/opt/minecraft
ExecStart=/usr/bin/java -Xms2G -Xmx2G -jar server.jar nogui
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
Then load and start it:
sudo systemctl daemon-reload
sudo systemctl enable --now minecraft
sudo systemctl status minecraft
To watch the live server log, use:
sudo journalctl -u minecraft -f
Step 8: Connect and manage players
In Minecraft, open Multiplayer, choose Add Server, and enter your VPS's public IP address. If you want a friendlier address, point a DNS A record such as mc.yourdomain.com at the server's IP.
To run admin commands, you need console access. One simple way is to enable RCON in server.properties (enable-rcon=true, plus a strong rcon.password) and use an RCON client locally on the server. Keep the RCON port closed in your firewall so it isn't reachable from the internet. Alternatively, run the server inside tmux or screen instead of systemd so you can attach to its console.
Once you have console access, these commands cover the basics:
whitelist add PlayerNameadds a player to the whitelist.op PlayerNamegives a player operator (admin) rights. Use sparingly.save-allforces the world to be written to disk.stopshuts the server down cleanly.
Step 9: Back up your world
Worlds take hours to build and seconds to lose. The world data lives in /opt/minecraft/world (plus world_nether and world_the_end on vanilla servers). A simple approach is to stop the server briefly, archive the folders, and start it again:
sudo systemctl stop minecraft
sudo tar -czf /root/mc-backup-$(date +%F).tar.gz -C /opt/minecraft world world_nether world_the_end
sudo systemctl start minecraft
Automate this with a nightly cron job during quiet hours, and copy the archives off the VPS so a server failure doesn't take your backups with it.
Performance tips
- Pre-generate or limit the world border so the server isn't generating new terrain constantly while players explore.
- Lower view-distance and simulation-distance if you see lag with several players online.
- Consider Paper, a popular high-performance server fork that supports Bukkit and Spigot plugins. It's a drop-in replacement for most vanilla setups, though some redstone and game mechanics behave slightly differently.
- Watch resource use with the tools in our server monitoring guide so you know when it's time to add RAM or CPU.
What about Bedrock Edition?
Bedrock players can't join a Java server without extra plugins. If your group mostly plays on consoles or phones, download the Bedrock Dedicated Server from minecraft.net instead. It uses UDP port 19132 by default, so you'd open that port rather than 25565.
Wrapping up
Hosting a Minecraft server on a VPS takes about half an hour: install Java, download the official jar, accept the EULA, open port 25565 and wrap it in a systemd service. Add a whitelist and nightly backups, and you have a private world that's always online for your friends, without depending on anyone's home computer staying awake.