Setting up a Minecraft server on Ubuntu 22.04 gives you complete control over your game world without the bloat of a desktop environment eating your RAM. The command-line approach might seem intimidating at first, but it’s actually the most efficient way to run a stable, high-performance server that won’t crash when your friends all log in at once.
What You Need Before Starting
Ubuntu 22.04 LTS is the sweet spot for Minecraft hosting—it’s stable, supported until 2027, and doesn’t waste resources on unnecessary graphical interfaces. You’ll need at least 2GB of RAM for a small server (5-10 players), but 4GB is better if you’re planning to use mods or host more people. A dual-core CPU works, but more cores help with chunk generation and plugin processing.
Make sure you have SSH access to your server and sudo privileges. If you’re running this on a home network, you’ll also need to forward port 25565 on your router. Cloud hosting providers like DigitalOcean or AWS work great, but they can get expensive fast. Want to skip the setup headaches? GameTeam.io offers managed Minecraft hosting starting at $1/GB with 20% off for new users.
Installing Java on Ubuntu 22.04
Minecraft runs on Java, and the version matters. Java 17 is the current requirement for Minecraft 1.18 and newer, while older versions need Java 8 or 11. Here’s how to install Java 17:
sudo apt update
sudo apt install openjdk-17-jre-headless -y
java -version
That last command confirms your Java installation. You should see something like “openjdk version 17.0.x” in the output. The headless version skips GUI components you don’t need on a server, saving memory for actual gameplay.
Creating a Dedicated Minecraft User
Running Minecraft as root is a security nightmare. Create a dedicated user account:
sudo adduser minecraft
sudo su - minecraft
This isolates your Minecraft server from system-critical processes. If something goes wrong with the server, it won’t take down your entire system.
Downloading and Configuring the Minecraft Server
Navigate to your new user’s home directory and create a folder for the server files:
mkdir ~/minecraft-server
cd ~/minecraft-server
Download the latest server JAR from Mojang’s official website. As of now, you can grab it with wget:
wget https://piston-data.mojang.com/v1/objects/[version-hash]/server.jar
Replace the URL with the current version from Minecraft’s official download page. The first time you run the server, it’ll create configuration files and exit:
java -Xmx2G -Xms1G -jar server.jar nogui
The -Xmx2G flag sets maximum memory to 2GB, while -Xms1G allocates 1GB at startup. Adjust these based on your available RAM—just leave at least 1GB free for the operating system.
Accepting the EULA
Minecraft won’t start until you accept the End User License Agreement. Edit the eula.txt file:
nano eula.txt
Change eula=false to eula=true, then save with Ctrl+X, Y, and Enter. Now you can actually start your server.
Optimizing Server Performance on Linux
The default server.properties file needs tweaking for optimal performance. Open it with nano:
nano server.properties
Key settings to adjust:
- view-distance=10 – Lower this to 6-8 if you’re experiencing lag. Each chunk loaded multiplies server load.
- max-players=20 – Set this realistically based on your hardware. Don’t promise 100 slots on a 2GB server.
- spawn-protection=0 – Unless you want a protected spawn area, set this to zero.
- enable-command-block=true – Only enable if you’re using command blocks for custom gameplay.
For servers with limited resources, consider installing Paper or Purpur instead of vanilla Minecraft. These optimized server implementations reduce lag significantly without changing gameplay. You can learn more about advanced Ubuntu server configurations for better performance.
Running Minecraft as a System Service
Manually starting your server every time is annoying. Create a systemd service to handle automatic startup and restarts. Exit from the minecraft user account back to your sudo-enabled user:
exit
sudo nano /etc/systemd/system/minecraft.service
Paste this configuration:
[Unit]
Description=Minecraft Server
After=network.target
[Service]
User=minecraft
WorkingDirectory=/home/minecraft/minecraft-server
ExecStart=/usr/bin/java -Xmx2G -Xms1G -jar server.jar nogui
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
Enable and start the service:
sudo systemctl enable minecraft
sudo systemctl start minecraft
sudo systemctl status minecraft
Your server now starts automatically on boot and restarts if it crashes. Check logs with sudo journalctl -u minecraft -f to troubleshoot issues.
Firewall Configuration and Port Forwarding
Ubuntu 22.04 uses UFW (Uncomplicated Firewall) by default. Allow Minecraft traffic:
sudo ufw allow 25565/tcp
sudo ufw enable
sudo ufw status
If you’re hosting from home, log into your router and forward port 25565 to your server’s local IP address. Every router interface is different, but look for “Port Forwarding” or “Virtual Server” in the settings. You’ll need your server’s internal IP (find it with ip addr show).
Using a Reverse Proxy for Multiple Servers
Running multiple Minecraft servers on one machine? Install BungeeCord or Velocity as a proxy. These tools let players connect to one IP address and get routed to different servers behind the scenes. It’s how large networks like Hypixel operate.
Backup Strategies That Actually Work
Minecraft worlds corrupt. Players grief. Drives fail. Automate your backups or lose everything eventually. Create a simple backup script:
nano ~/backup-minecraft.sh
Add this content:
#!/bin/bash
BACKUP_DIR="/home/minecraft/backups"
WORLD_DIR="/home/minecraft/minecraft-server/world"
DATE=$(date +%Y-%m-%d-%H%M)
mkdir -p $BACKUP_DIR
tar -czf $BACKUP_DIR/world-backup-$DATE.tar.gz -C $WORLD_DIR .
find $BACKUP_DIR -name "world-backup-*.tar.gz" -mtime +7 -delete
Make it executable and add to cron:
chmod +x ~/backup-minecraft.sh
crontab -e
Add this line to run backups daily at 3 AM:
0 3 * * * /home/minecraft/backup-minecraft.sh
This keeps seven days of backups and automatically deletes older ones. Store critical backups offsite using rsync or cloud storage solutions.
Common Issues and Quick Fixes
Server won’t start: Check Java version compatibility. Minecraft 1.18+ requires Java 17. Run java -version to verify.
Out of memory errors: Either increase the -Xmx value in your startup command or reduce view-distance in server.properties. Also check for memory leaks in plugins.
Players can’t connect: Verify firewall rules with sudo ufw status and confirm port forwarding is configured correctly. Test with telnet your-ip 25565 from an external network.
Lag spikes: Install Spark profiler to identify performance bottlenecks. Usually it’s either poorly optimized plugins, too many entities, or insufficient RAM allocation.
FAQ
Can I run Minecraft server on Ubuntu 20.04 instead of 22.04?
Yes, the process is nearly identical. Ubuntu 20.04 LTS is still supported until 2025, but 22.04 offers better performance and newer package versions. Both work fine for Minecraft hosting.
How much RAM does a Minecraft server actually need?
Vanilla Minecraft needs 2GB minimum for 5-10 players. Add 1GB for every 10 additional players, and double that if you’re running heavy modpacks. A 20-player server with plugins runs comfortably on 4-6GB.
Should I use Docker for Minecraft on Ubuntu?
Docker adds complexity without major benefits for single-server setups. It’s useful if you’re running multiple isolated servers or need easy migration between hosts. For most people, a direct installation is simpler and performs better.
Can I run Bedrock and Java servers on the same Ubuntu machine?
Absolutely. Bedrock uses port 19132 by default, so there’s no conflict with Java Edition’s 25565. Just make sure you have enough RAM for both servers and configure firewall rules for both ports.
What’s the best way to update my Minecraft server?
Stop the server with sudo systemctl stop minecraft, backup your world folder, replace the server.jar with the new version, and restart. Always test updates on a copy of your world first—some updates break plugins or change world generation.
Running a Minecraft server on Ubuntu 22.04 gives you full control over performance, plugins, and customization that hosted solutions often restrict. The command-line setup takes an hour, but you’ll have a stable server that can handle your growing player base without monthly costs scaling out of control.
