Complete guide to installing and running a Minecraft Java Edition dedicated server on Ubuntu/Debian Linux.
Install Java 21 (or newer) on your Linux server.
# Update package list
sudo apt update
# Install Java 21 JDK
sudo apt install -y openjdk-21-jdk-headless
# Verify installation
java -versionCreate a dedicated user and directory for the Minecraft server.
# Create minecraft user
sudo useradd -r -m -U -d /opt/minecraft -s /bin/bash minecraft
# Create server directory
sudo mkdir -p /opt/minecraft/server
sudo chown -R minecraft:minecraft /opt/minecraftDownload the latest Minecraft server JAR file.
# Switch to minecraft user
sudo -u minecraft -s
# Navigate to server directory
cd /opt/minecraft/server
# Download the latest server.jar (replace URL with latest version)
wget https://piston-data.mojang.com/v1/objects/SERVER_JAR_URL/server.jarGet Download URL
Visit minecraft.net/download/server to get the latest server.jar download URL.
Run the server once to generate files, then accept the EULA.
# First run to generate files
java -Xmx1G -Xms1G -jar server.jar nogui
# Accept the EULA
echo "eula=true" > eula.txtConfigure your server by editing server.properties:
# Edit server properties
nano server.propertiesUse our Config Builder to generate a customized configuration.
Open the required port in your firewall.
# Using UFW (Ubuntu)
sudo ufw allow 25565/tcp
sudo ufw reload
# Or using iptables
sudo iptables -A INPUT -p tcp --dport 25565 -j ACCEPTCloud Providers
If using a cloud provider (AWS, GCP, Azure, etc.), also configure their security group/firewall to allow port 25565.
Create a systemd service to manage the server automatically.
[Unit]
Description=Minecraft Server
After=network.target
[Service]
User=minecraft
WorkingDirectory=/opt/minecraft/server
ExecStart=/usr/bin/java -Xmx4G -Xms2G -jar server.jar nogui
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target# Create the service file
sudo nano /etc/systemd/system/minecraft.service
# Enable and start the service
sudo systemctl daemon-reload
sudo systemctl enable minecraft
sudo systemctl start minecraft
# Check status
sudo systemctl status minecraftIf you need console access, you can use screen instead of systemd.
# Install screen
sudo apt install -y screen
# Start server in screen session
sudo -u minecraft screen -S minecraft -d -m java -Xmx4G -Xms2G -jar /opt/minecraft/server/server.jar nogui
# Attach to console
sudo -u minecraft screen -r minecraft
# Detach from console (Ctrl+A, then D)Once your server is running, players can connect using your server's IP address.
sudo journalctl -u minecraft -fsudo systemctl stop minecraftsudo systemctl restart minecraft