LochStudios  /  Help Centre  /  Game Servers  /  Set up a Minecraft Java Edition server on Linux

Set up a Minecraft Java Edition server on Linux

Install Java, download the official Minecraft server jar, and open port 25565 on your LochStudios KVM VPS so players can join.

Updated

This is the official Minecraft Java Edition dedicated server (vanilla), running on a LochStudios KVM VPS. You install Java, download the jar from Minecraft, accept the EULA, and listen on TCP port 25565.

Need a VPS first? See VPS. On a dedicated server, open a support ticket and we will size the box with you.

This article is not Minecraft Bedrock. Bedrock uses a different server and UDP port 19132.

Before you start

  1. Sign in at the portal, open the VPS service, and keep that page open. Copy the IPv4 from there. Do not guess a hostname.
  2. Connect with a sudo user, or root on a fresh box.

- Connect to your VPS via SSH from macOS or Linux
- Connect to your VPS via SSH from Windows

  1. If this VPS is new, patch it and create a sudo user first: First steps on a new VPS.

If SSH from your computer will not connect, open the console on the same VPS service. That session does not need port 22 from your network.

We document Ubuntu 24.04 LTS. Debian is close. For AlmaLinux or Rocky Linux, open a support ticket and we will match the packages.

RAM

Leave memory for the operating system. Do not set -Xmx to the full VPS size.

VPS RAMSuggested -Xmx / -XmsWhat it is for
4 GB2GSmall vanilla world, a handful of players
8 GB4GComfortable vanilla (Minecraft's own example uses 4G)
16 GB8G to 10GMore players, or a heavier world

A 2 GB VPS is only a smoke test. Current Java Edition wants more. Pick a size on VPS, or open a support ticket and tell us how many players you expect.

If the kernel is swapping hard, add swap: Add Swap Space to Your VPS.

Java version

Match Java to the Minecraft version you will run. The official server page is the source of truth.

Minecraft JavaJava needed
26.1 and newerJava 25
1.20.5 through 1.21.xJava 21
1.18 through 1.20.4Java 17

Current official jars (26.x) need Java 25. Installing default-jre is not enough if that package is an older release.

Step 1: Install Java

On Ubuntu or Debian:

sudo apt update
sudo apt install -y openjdk-25-jre-headless
java -version

The first line of java -version should mention 25.

If apt cannot find openjdk-25-jre-headless:

sudo add-apt-repository universe
sudo apt update
sudo apt install -y openjdk-25-jre-headless

Still missing? Open a support ticket and we will install the runtime with you. Do not mix random third-party Java downloads onto the VPS.

Running an older 1.21.x world instead:

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

If more than one Java is installed, sudo update-alternatives --config java picks the default.

Step 2: Create a dedicated minecraft user

Do not run the game as root.

sudo useradd -m -s /bin/bash minecraft
sudo -u minecraft mkdir -p /home/minecraft/server

Later articles in this section assume this user and /home/minecraft/server. Keep those paths.

Step 3: Download the official server jar

  1. On your computer, open the official download page: minecraft.net/download/server.
  2. Copy the server.jar (or minecraft_server.*.jar) download URL for the version you want. The hash in that URL changes every release. Do not reuse an old one from a blog.
  3. On the VPS, download it as server.jar:
sudo -u minecraft wget -O /home/minecraft/server/server.jar 'PASTE_THE_JAR_URL'
ls -lh /home/minecraft/server/server.jar

The file should be tens of megabytes. A few-kilobyte file is an HTML error page, not the jar. Delete it and copy the URL again.

Step 4: Accept the EULA

You must agree to Minecraft's EULA before the process will start. Read it on the download page, then:

printf 'eula=true\n' | sudo -u minecraft tee /home/minecraft/server/eula.txt

Do not run sudo -u minecraft echo ... > eula.txt. The > redirect runs as your shell user (often root) and can leave a file the minecraft account cannot write.

Step 5: Set server.properties

Write a starter file. You can change these later and restart.

sudo -u minecraft tee /home/minecraft/server/server.properties > /dev/null << 'EOF'
# Minecraft server properties
server-port=25565
max-players=10
gamemode=survival
difficulty=normal
online-mode=true
enable-command-blocks=false
spawn-protection=16
view-distance=10
simulation-distance=10
white-list=false
motd=A Minecraft Server
EOF
KeyWhat it does
server-portTCP port players use. Default 25565. If you change it, change the firewall too.
max-playersSimultaneous players. Start low; raise it when RAM and CPU stay comfortable.
gamemodesurvival, creative, adventure, or spectator.
difficultypeaceful, easy, normal, or hard.
online-modetrue requires a genuine Minecraft Java account. Leave it on for a public server.
view-distanceChunks sent to each player. Higher uses more CPU and RAM. 8 to 10 is a sensible start.
white-listSet true later if only named accounts may join.

online-mode=false lets anyone join with any name. We do not recommend that on a server reachable from the internet.

Fix ownership if you created any file as root:

sudo chown -R minecraft:minecraft /home/minecraft/server

Step 6: Open port 25565

Two filters can block players: the Firewall tab on the VPS in the portal, then UFW (or firewalld) on the OS. Full walkthrough: Open the Right Firewall Ports for Your Game Server.

Java Edition uses TCP 25565.

  1. In the portal, open the VPS, then the Firewall tab.
  2. If you already have Drop rules, add an Accept for TCP 25565 (and keep SSH 22/TCP allowed) above those Drops.
  3. On Ubuntu or Debian:
sudo ufw allow 25565/tcp
sudo ufw status

If you have never enabled UFW, do Set up a UFW firewall on Ubuntu first. Allow SSH (22/tcp) before sudo ufw enable.

Unsure about an existing portal rule? Open a support ticket. Tell us the VPS service. Do not put the password in the ticket.

Step 7: Start the server once

Use a heap that fits the table above. Example for an 8 GB VPS (4G):

sudo -u minecraft -H bash -c 'cd /home/minecraft/server && java -Xmx4G -Xms4G -jar server.jar nogui'
  • -Xmx is the maximum heap. -Xms is the starting heap. Keep them equal.
  • nogui skips the desktop window. Correct for a VPS.

The first start generates the world and can take several minutes. When it prints that it is done, the process is listening.

Type stop and press Enter for a clean shutdown. Do not use Ctrl+C as your usual stop.

Confirm it listened:

sudo ss -tulnp | grep 25565

You should see java on 0.0.0.0:25565 or [::]:25565. Listening only on 127.0.0.1 means players outside the VPS cannot join.

Step 8: Join from Minecraft

  1. Use the IPv4 on the VPS in the portal. Do not test only from the VPS itself.
  2. On your PC, open Minecraft Java Edition (the same major version as the jar).
  3. Multiplayer, then Add Server. Address is YOUR.IPV4.HERE:25565 (or just the IPv4 if you left the default port).

From another machine, a TCP check:

nc -zv YOUR.IPV4.HERE 25565

A reachable port prints succeeded or open. The real test is still a player joining.

Want a name instead of the raw IPv4? In the portal go to Domains, open the domain, then DNS, and add an A record to that IPv4. AtlasDNS is the default. See Point your domain at your hosting.

Keep it running after you log out

A jar started in your SSH session dies when the session ends. Run it as a systemd service:

The Minecraft unit expects User=minecraft, WorkingDirectory=/home/minecraft/server, and server.jar. Match the -Xmx value you used here.

If it will not start, or nobody can join

Unsupported class file or a Java version error. You installed the wrong Java for that jar. Check java -version against the table above.

It exits about the EULA. eula.txt must contain eula=true and be owned by minecraft.

server.jar is tiny. The download was not the jar. Get a fresh URL from the official page.

The port test fails. Check the portal Firewall tab, then sudo ufw status, then sudo ss -tulnp. Details: Open the Right Firewall Ports for Your Game Server.

Players cannot join but nc works. They may be on Bedrock, or on a different Java version than the jar.

The VPS feels slow. Lower view-distance and max-players, or raise -Xmx only if free RAM remains. Watch it with Monitor Server Resources.

Still stuck? Open a support ticket. Tell us the VPS service, the Minecraft version, and java -version. Do not send the password.

What to do next

A step is unclear? Open a support ticket and we will walk through the VPS with you.


Was this article helpful?

← Back to Game Servers