🎮
VPS

Running your own Minecraft Java Edition server on a VPS gives you full control over your in-game world: you set the rules, install plugins, and keep it online 24/7 without leaving a home computer running. This guide walks you through setting up a server on Ubuntu 22.04 or 24.04 step by step, from preparing the system and installing Java to running it as a rock-solid systemd service.

Before You Begin

Before diving in, you'll want a VPS running Ubuntu 22.04 LTS or 24.04 LTS with root access or a sudo-capable user, plus a public IP address that your friends can connect to. The single most important resource is memory (RAM), because Minecraft Java is fairly demanding.

As a rule of thumb, a Vanilla server for a handful of players needs at least 2GB of RAM, but for smooth play with 4-6 friends at once, 4GB or more is recommended. If you plan to run plugins or mods, budget even more headroom.

If you're looking for a VPS to host a Minecraft server, AsiaGB's Linux VPS plans use SSD storage and start at 500 THB/month, making them a solid fit for small-to-medium servers. They're managed conveniently through DirectAdmin.

Update the System and Install Basic Tools

First, refresh the package list and install the tools you'll need, such as wget for downloads and screen just in case. Log in via SSH and run the following.

sudo apt update && sudo apt upgrade -y
sudo apt install -y wget screen nano

Always updating the system first reduces package incompatibility issues and closes any security holes lingering in the base image.

Install the Right Java Version

Minecraft Java Edition relies on the Java runtime, and the Java version must match the game version. Install the wrong one and the server simply refuses to start.

Minecraft VersionRequired JavaInstall Package
1.20.5+ / 1.21Java 21openjdk-21-jre-headless
1.17 – 1.20.4Java 17openjdk-17-jre-headless
1.16 or olderJava 8openjdk-8-jre-headless

For the latest Minecraft (1.21), install Java 21 with the command below. We use the headless package because a server needs no graphical interface, saving disk space.

sudo apt install -y openjdk-21-jre-headless
java -version

Running java -version should report version 21. If you see a different version or the command isn't found, the installation didn't complete correctly, so double-check the package name.

Create a Dedicated Minecraft User

For security, you should never run a game server as root, because a vulnerability would hand an attacker the entire system. The better approach is to create a separate, limited-privilege user just for the server.

sudo useradd -r -m -d /opt/minecraft minecraft
sudo mkdir -p /opt/minecraft
sudo chown -R minecraft:minecraft /opt/minecraft

This creates a system user named minecraft with its home set to /opt/minecraft, which we'll use to store all the server files.

Download server.jar

Download the official server file only from minecraft.net. Never grab it from untrusted sources, as those may hide malware. Go to the minecraft.net server download page, copy the link to the latest server.jar, and download it into the folder.

sudo su - minecraft
cd /opt/minecraft
wget -O server.jar https://piston-data.mojang.com/v1/objects/<HASH>/server.jar

Each version's download link contains a unique hash that changes over time. Always copy the latest link directly from minecraft.net. Don't reuse an old link, or you may end up with an outdated version or a dead URL.

First Run and Accepting the EULA

On the first run, the server generates an eula.txt file and then immediately stops, because you must accept Mojang's license agreement first. Try running it as the minecraft user.

cd /opt/minecraft
java -Xms2G -Xmx4G -jar server.jar nogui

After that first run, open eula.txt and change eula=false to eula=true to confirm you accept the agreement.

nano /opt/minecraft/eula.txt
# change to eula=true and save

Configure server.properties

The server.properties file is the heart of your configuration. Open it with nano and tune the key values to your liking.

Always keep online-mode=true. It blocks fake accounts and stops people from impersonating other players. Turn it off and anyone could name themselves after your admin and wreak havoc.

Create a systemd Service for Auto-Start

While you can run it under screen, a systemd service is far better: the server starts automatically on reboot and restarts itself if it crashes. Create the unit file as root.

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

Add the following contents.

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

[Service]
User=minecraft
WorkingDirectory=/opt/minecraft
ExecStart=/usr/bin/java -Xms2G -Xmx4G -jar server.jar nogui
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target

Then tell systemd to reload, enable, and start the server.

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

Open the Firewall and Connect

Minecraft uses port 25565/tcp by default. If you have ufw enabled, you must allow this port, or your friends won't be able to connect.

sudo ufw allow 25565/tcp
sudo ufw reload

Once everything is ready, launch Minecraft on your own machine, go to Multiplayer, choose Add Server, and enter your VPS IP followed by :25565 (or just the IP, since it's the standard port). Then jump right in.

Maintenance and Performance Tuning

After installation, keep the server running smoothly for the long haul. Start by regularly backing up the world folder so you can restore instantly if something goes wrong.

For performance tuning, set -Xms and -Xmx to match your available RAM, leaving at least 1GB for the operating system. If you have many players and need higher performance, consider running a Paper server, which is optimized to be faster than Vanilla. To watch logs in real time, use sudo journalctl -u minecraft -f.

That's it. You now have your own Minecraft Java Edition server running 24/7 on an Ubuntu VPS, ready for your friends to join the adventure.

Frequently Asked Questions

How much RAM do I need to run a Minecraft server?

At least 2GB for a handful of players, but 4GB or more is recommended for smooth play with 4-6 friends, and you should budget even more if you install plugins or mods.

Which Java version does the latest Minecraft require?

Minecraft 1.20.5 and up, including 1.21, requires Java 21, while versions 1.17 through 1.20.4 use Java 17; install it with sudo apt install openjdk-21-jre-headless.

Why does the server stop immediately on its first run?

Because it generates an eula.txt file and waits for you to accept Mojang's license first; edit the file to set eula=true, then start the server again.

My friends can't connect to the server, how do I fix it?

Make sure port 25565/tcp is open on the firewall with sudo ufw allow 25565/tcp, verify the server is running with sudo systemctl status minecraft, and confirm you're using the correct public IP.

Ready to launch your Minecraft server?

AsiaGB Linux VPS (SSD, DirectAdmin, 99% uptime) from 500 THB/month — Thailand & Singapore datacenters for low ping, perfect for Minecraft servers of any size.

View VPS Plans

View all affordable VPS Thailand plans →