natbox.io

Guides / Minecraft server

Run a Minecraft server

About 15 minutes. Use Box Plus (2 GB RAM) for a few friends; Nano and Box are too small for a modern Java server. Ubuntu 24.04 commands.

Players connect to natbox.io:10001, where 10001 is one of your forwarded ports. The server listens on that same port number inside.

1. Install Java and the server

apt update && apt install -y openjdk-21-jre-headless
useradd -r -m -d /opt/minecraft minecraft
cd /opt/minecraft
# download server.jar for your version from minecraft.net/download/server, then:
sudo -u minecraft java -jar server.jar nogui   # first run creates eula.txt and stops
sed -i 's/eula=false/eula=true/' eula.txt
sed -i 's/^server-port=.*/server-port=10001/' server.properties

2. Start it automatically

Create /etc/systemd/system/minecraft.service:

[Unit]
Description=Minecraft server
After=network-online.target

[Service]
User=minecraft
WorkingDirectory=/opt/minecraft
ExecStart=/usr/bin/java -Xms1G -Xmx1500M -jar server.jar nogui
Restart=on-failure

[Install]
WantedBy=multi-user.target
systemctl daemon-reload && systemctl enable --now minecraft
journalctl -u minecraft -f

Keep -Xmx a few hundred MB below your plan's RAM. Memory is a hard limit with no swap: if Java asks for more, the process is stopped.

3. Connect

In Minecraft choose Multiplayer → Add server and enter natbox.io:10001. For a name like mc.example.com without a port, add an SRV record _minecraft._tcp.mc pointing to natbox.io port 10001.

Good to know