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 Minecraft server jar, and configure basic settings to run your own Minecraft Java Edition server.

Updated

Overview

Running a Minecraft Java Edition server on your Linux VPS gives you full control over your game world and player list. This guide covers installing Java, downloading the official server software, and starting your first server.

Prerequisites

  • A Linux VPS (Ubuntu 22.04 / Debian 11+ recommended)
  • Root or sudo access
  • At least 2 GB RAM available (4 GB+ recommended for multiple players)
  • Port 25565 open in your firewall

Steps

Step 1: Update your system and install Java

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

If you need a specific Java version (e.g., Java 17 for newer servers), install it explicitly:

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

Step 2: Create a dedicated user for the server (recommended)

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

Step 3: Download the official Minecraft server jar

Visit minecraft.net/download/server to find the latest server jar URL, or download directly:

cd /home/minecraft/server
sudo -u minecraft wget https://launcher.mojang.com/v1/objects/[HASH]/server.jar

Replace [HASH] with the actual hash from the download page. Alternatively, use a mirror or the latest stable version (adjust the URL as needed).

Step 4: Accept the EULA

cd /home/minecraft/server
sudo -u minecraft echo "eula=true" > eula.txt

Step 5: Configure server.properties

Create or edit the server configuration file:

sudo -u minecraft touch /home/minecraft/server/server.properties

Add or modify key settings:

sudo -u minecraft tee /home/minecraft/server/server.properties > /dev/null << 'EOF'
# Minecraft server properties
server-port=25565
max-players=20
gamemode=survival
difficulty=2
online-mode=true
enable-command-blocks=false
spawn-protection=16
view-distance=10
level-seed=
EOF

Key options:
- server-port: The port players connect to (open in your firewall)
- max-players: Number of simultaneous players
- gamemode: survival, creative, adventure, spectator
- difficulty: 0 (peaceful) to 3 (hard)
- online-mode: true = require Minecraft account login; false = allow cracked clients
- view-distance: 3–32 (higher = more CPU/RAM usage)

Step 6: Open your firewall

For UFW (Ubuntu):

sudo ufw allow 25565/tcp
sudo ufw allow 25565/udp
sudo ufw status

For AWS Security Groups, GCP Firewall, or other cloud providers, open TCP/UDP port 25565 to 0.0.0.0/0 (or your chosen IP range).

Step 7: Start the server

cd /home/minecraft/server
sudo -u minecraft java -Xmx1024M -Xms1024M -jar server.jar nogui
  • -Xmx1024M: Maximum RAM (adjust based on your server size)
  • -Xms1024M: Starting RAM (match -Xmx for consistency)
  • nogui: No graphical interface (efficient for headless servers)

The server will generate world files and then print "Done! For help, type 'help'".

Step 8: Verify the server is running

From your local machine:

nslookup your-server-ip
telnet your-server-ip 25565

Or open Minecraft Java Edition, click "Multiplayer" → "Add Server", and enter your-server-ip:25565.

Tips

  • Server won't start? Check Java is installed (java -version), the jar file exists, and the EULA is accepted.
  • Low FPS / lag? Increase -Xmx RAM allocation, lower view-distance, or reduce max-players.
  • Backups: Regularly copy the /home/minecraft/server/world directory to a safe location.
  • Update servers: Download a new jar and restart the server; old world data is compatible with newer versions.

Next Steps

  • Run a Minecraft server as a systemd service to auto-start on reboot
  • Add plugins or mods to customize gameplay

Was this article helpful?

← Back to Game Servers