Back to Setup Guides
    Linux

    Minecraft Server Setup on Linux

    Complete guide to installing and running a Minecraft Java Edition dedicated server on Ubuntu/Debian Linux.

    1Install Java

    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 -version

    2Create Server User and Directory

    Create 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/minecraft

    3Download the Minecraft Server

    Download 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.jar

    Get Download URL

    Visit minecraft.net/download/server to get the latest server.jar download URL.

    4Accept EULA and Configure

    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.txt

    Configure your server by editing server.properties:

    # Edit server properties
    nano server.properties

    Use our Config Builder to generate a customized configuration.

    5Configure Firewall

    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 ACCEPT

    Cloud Providers

    If using a cloud provider (AWS, GCP, Azure, etc.), also configure their security group/firewall to allow port 25565.

    6Create Systemd Service

    Create a systemd service to manage the server automatically.

    /etc/systemd/system/minecraft.service
    [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 minecraft

    7(Optional) Using Screen for Console Access

    If 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)

    Connecting to Your Server

    Once your server is running, players can connect using your server's IP address.

    • Check logs: sudo journalctl -u minecraft -f
    • Stop server: sudo systemctl stop minecraft
    • Restart server: sudo systemctl restart minecraft