TürkiyeVPS

Setting Up a Minecraft Server: Step by Step on a Linux VPS (Java Edition)

Set up a Minecraft Java Edition server for you and your friends from scratch on Ubuntu 24.04: Java 21, server.jar or Paper, memory settings, the firewall, a systemd service and world backups.

8 min read

When you have your own Minecraft server, you make the rules: who can join, which plugins run, when the world gets backed up. You can host a server on your home computer, but the game goes down when the computer is switched off, and you have to deal with port forwarding on your router. A Linux VPS stays on day and night and comes with a fixed IP address.

In this guide we'll set up a Minecraft: Java Edition server on Ubuntu 24.04. Bedrock Edition (the mobile, console and Windows version) needs separate server software; the steps here are for Java Edition.

1. Install Java 21

Connect to the server via SSH. Minecraft 1.20.5 and later require at least Java 21. This version is available in the Ubuntu 24.04 repositories; since the server has no graphical interface, the "headless" package is enough:

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

You should see openjdk version "21... in the output. Future Minecraft versions may require a newer Java. If you get an UnsupportedClassVersionError when the server starts, check the required Java version in the release notes and use apt search openjdk to see which versions are in the repository.

If you're new to the command line, you may want to read our basic Linux commands article first.

2. Create a separate user

Don't run the server as root. If a vulnerability is found in a plugin or the server software, an attacker should only be able to reach this user's files:

sudo adduser --system --group --home /opt/minecraft minecraft
sudo -u minecraft mkdir -p /opt/minecraft/server

3. Download the server file

There are two common options:

  • The official server (vanilla): the unmodified server published by Mojang. Go to the "Download Minecraft: Java Edition Server" page on minecraft.net and copy the server.jar link. Because the link changes with every version, we don't give a fixed address here.
  • Paper: server software downloaded from papermc.io that includes performance improvements and can run Bukkit/Spigot plugins. If you want plugins, or if performance matters as your player count grows, most people choose Paper. Copy the link for the version you want from Paper's download page.

Download the file with the link you copied and save it as server.jar:

cd /opt/minecraft/server
sudo -u minecraft wget -O server.jar "KOPYALADIGINIZ_BAGLANTI"

Replace KOPYALADIGINIZ_BAGLANTI with the link you copied.

4. First run and the EULA

Run the server once by hand. On first start it creates the necessary files and shuts down because the EULA hasn't been accepted:

sudo -u minecraft java -Xms1G -Xmx1G -jar server.jar nogui

After reading the Minecraft End User License Agreement (EULA), accept it:

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

5. Memory settings: -Xms and -Xmx

-Xmx sets the maximum memory Java may use, and -Xms the memory it allocates at startup. Setting both to the same value is a common approach on servers. The key point is not to give all of the server's RAM to Minecraft: leave around 1–1.5 GB for the operating system and Java's own overhead. For example, on a server with 4 GB of RAM, -Xms2G -Xmx2G or at most -Xms3G -Xmx3G is reasonable.

Giving more memory than needed isn't good either; the garbage collector has to clean a larger area, and momentary stutters can increase.

6. Basic server.properties settings

The /opt/minecraft/server/server.properties file is the server's main configuration file:

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

The lines to look at first:

motd=Arkadaslarla Minecraft
max-players=10
online-mode=true
white-list=true
enforce-whitelist=true
difficulty=normal
view-distance=10
simulation-distance=8
  • motd: the description shown in the server list.
  • online-mode=true: makes sure players are verified with a real Minecraft account. If you set it to false, anyone can join with any username (including yours); don't turn it off.
  • white-list and enforce-whitelist: only players you allow can join. Unless you're setting up a public server, this is the most effective protection.
  • view-distance and simulation-distance: set how many chunks are loaded around each player. If the server is struggling, these are the first values to lower.

You add players to the whitelist from the server console with the command whitelist add OyuncuAdi. We'll see how to send commands to the console below.

7. Open the port in the firewall

Minecraft Java Edition uses port 25565/TCP by default:

sudo ufw allow OpenSSH
sudo ufw allow 25565/tcp
sudo ufw enable

Make sure you add the SSH rule before running ufw enable; otherwise your connection may be cut off. For the general security of the server, also apply the steps in our Linux server security guide.

8. A systemd service: running permanently without screen

Running inside screen or tmux is fine for testing, but the game won't start on its own when the server reboots. With systemd we'll get both automatic startup and a clean shutdown. To be able to send commands to the console, we'll use a FIFO (named pipe); the server's input will be connected to this file.

First the socket unit:

sudo nano /etc/systemd/system/minecraft.socket
[Unit]
Description=Minecraft konsol girisi

[Socket]
ListenFIFO=/run/minecraft.stdin
SocketUser=minecraft
SocketGroup=minecraft
SocketMode=0660

[Install]
WantedBy=sockets.target

Then the service unit:

sudo nano /etc/systemd/system/minecraft.service
[Unit]
Description=Minecraft Java sunucusu
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=minecraft
Group=minecraft
WorkingDirectory=/opt/minecraft/server
Sockets=minecraft.socket
StandardInput=socket
StandardOutput=journal
StandardError=journal
ExecStart=/usr/bin/java -Xms2G -Xmx2G -jar server.jar nogui
ExecStop=/bin/sh -c 'if kill -0 $MAINPID 2>/dev/null; then echo stop > /run/minecraft.stdin; while kill -0 $MAINPID 2>/dev/null; do sleep 1; done; fi'
TimeoutStopSec=120
SuccessExitStatus=0 1 143
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target

If the server is still running, the ExecStop line sends it the stop command and waits for the world to be saved and the process to exit. That way the world isn't left half-saved when you run systemctl stop or reboot the server. The StandardOutput=journal line is important: because we connected the input to the FIFO, we have to state explicitly that output goes to the journal.

Enable and start the services:

sudo systemctl daemon-reload
sudo systemctl enable --now minecraft.socket minecraft.service
systemctl status minecraft

To send a command to the console and watch the output:

echo "whitelist add OyuncuAdi" | sudo tee /run/minecraft.stdin > /dev/null
journalctl -u minecraft -f

You can send any console command, such as say, op or save-all, the same way.

9. Back up the world

World data lives in the world folder inside the server folder. Paper keeps the Nether and End dimensions separately in the world_nether and world_the_end folders. To take a consistent backup while the server is running, temporarily turn off auto-saving, flush the data to disk, archive it and turn saving back on:

sudo mkdir -p /var/backups/minecraft
echo "save-off" | sudo tee /run/minecraft.stdin > /dev/null
echo "save-all flush" | sudo tee /run/minecraft.stdin > /dev/null
sleep 15
sudo tar czf /var/backups/minecraft/dunya-$(date +%F-%H%M).tar.gz -C /opt/minecraft/server world world_nether world_the_end
echo "save-on" | sudo tee /run/minecraft.stdin > /dev/null

The vanilla server only has the world folder, so remove the other two folders from the tar line. You can put these commands in a script and add it to root's crontab for daily backups. Also copy the backups off the server regularly; a backup that only sits on the same disk won't save you if the disk has a problem.

How much RAM and CPU do you need?

It's hard to give an exact figure; the number of plugins, the explored area, the farms players build and the view distance all directly affect memory needs. As a rough starting estimate:

  • 2–5 players, no plugins: allocating 2 GB to Minecraft is usually enough (3–4 GB of RAM on the server in total).
  • 5–15 players or a few plugins: allocating 3–4 GB is more comfortable.
  • Modpacks or busier servers: 6 GB or more may be needed.

The main game loop of a Minecraft server runs largely on a single CPU core, so single-core performance and stable resources matter more than the number of cores. A VDS, whose resources aren't shared with others, offers a more consistent experience on busy servers. If you'd rather not deal with the setup, take a look at our game server plans: they come with AMD EPYC 7642 vCPUs, DDR4 ECC RAM and NVMe storage, and after payment our team sets up the server and hands it over to you.

Frequently Asked Questions

Can Bedrock Edition players join this server?

Not directly; Java and Bedrock use different protocols. If you use Paper, a plugin such as Geyser can let Bedrock players connect to a Java server. For that you also need to open the UDP port Bedrock uses in the firewall.

The server says "Unable to access jarfile". Why?

The file name or folder is wrong. Check with ls -l /opt/minecraft/server that the server.jar file is there and that it's in the same folder as the WorkingDirectory in the systemd service.

Players can't connect. Where should I look?

First check that the service is running with systemctl status minecraft and that the 25565/tcp rule exists with sudo ufw status. If the whitelist is on, make sure you've added the player and that the player is using the same Minecraft version as the server.

How do I update the server to a new Minecraft version?

First back up the world, then stop the server with sudo systemctl stop minecraft, download the new server.jar over the old one and start the service again. If you use plugins, check beforehand that they're compatible with the new version.

Can players connect with a domain name?

Yes. Once you create an A record on your domain pointing to the VPS's IP address, players can connect with an address like mc.ornek.com instead of the IP. Since the default port is 25565, they don't need to type a port.