Skip to main content
How To Set Up a Minecraft Server - Virtarix Blog

How To Set Up a Minecraft Server

November 18, 2025 · Blog / Technical Guides

Setting up your own Minecraft server takes 20-60 minutes and costs $5-60 monthly, depending on your player count. You get complete control over your gaming experience, choose your own mods, and create the exact world you want.

This guide covers self-hosting on a VPS or cloud server with optimized performance and proper security. We'll show you production-ready configurations used by professional server hosts, with step-by-step instructions for security hardening, performance tuning, and automated maintenance.

Hosting options explained

Self-hosting on your PC

Running the server on your computer gives you immediate access without monthly fees. Your PC must remain running at all times, which can lead to higher electricity costs and performance issues when multitasking. Security becomes your responsibility entirely.

Self-hosting on a VPS or cloud server

A VPS is a remote computer you rent that runs independently from your home setup. Unlike shared hosting, you get dedicated resources and full control over the server software.

VPS plans suitable for Minecraft start at $5-8/month for 1-10 players. Key features to look for:

  • Dedicated CPU cores (not shared vCPU)
  • NVMe SSD storage (3-5x faster than SATA)
  • Unmetered bandwidth (2-3 Mbps per player minimum)
  • Full root access (required for this guide)
  • Snapshots/backups (critical for world protection)

Your server stays online continuously without relying on your personal computer. Players can connect anytime, and your home internet doesn't affect server performance. You can scale resources up or down based on player count without buying new hardware.

Renting a managed server

Managed hosting providers offer one-click setups but cost $15-60+/month with less customization.

Hosting cost comparison

Hosting type Cost inputs Capacity test Operational review
Home PC Hardware already owned, measured electricity, network changes, backup power Test the target version, mods, player simulation, and upload path Local power, ISP, router, security, monitoring, backup, and recovery
VPS Current plan, transfer, backups, support, and operations time Benchmark the selected plan and region with the target server build Hardening, patching, monitoring, backup restore, and resize path
Managed Minecraft host Current tier, player or resource limits, add-ons, backups, and renewal terms Test the exact tier with the target mods and player profile Confirm control-panel limits, support scope, export, restore, and cancellation
Dedicated server Current hardware quote, setup, transfer, support, and operations time Benchmark the selected hardware and network Provisioning lead time, remote console, replacement, backup, and recovery

Minimum requirements for self-hosting

CPU: Modern quad-core (Intel i3-13100 or AMD Ryzen 5 7600). Single-core speed matters most for Minecraft's single-threaded world simulation. ARM-based cloud instances (AWS Graviton, Oracle Ampere) provide excellent price-to-performance but may have compatibility issues with some plugins.

RAM: Allocate based on your server type:

  • 4GB: Vanilla (1-10 players)
  • 6-8GB: Light mods/plugins (10-20 players)
  • 12GB+: Heavy modpacks (20+ players)
  • Always reserve 2GB for OS overhead

Storage: NVMe SSD strongly recommended for 20+ players or worlds >5GB. SATA SSD minimum. Never use HDD because world loading will create unacceptable lag. Budget 10-20GB for the server, plus 5-10GB per 1000 chunks of world generation.

Network: 2-3 Mbps upload per player minimum for Minecraft 1.20 and above. For 10 concurrent players, expect 20-30 Mbps sustained usage. Under 50ms latency is ideal; test your connection to the datacenter before committing to a provider.

OS: Ubuntu Server 24.04 LTS or Debian 12 recommended (lower resource usage than Windows Server, free, and better documented for Minecraft).

Server setup

Preparing your environment

Secure your server

Connect to your VPS using SSH:

Connect to the VPS as root
ssh root@your_server_ip

Create a non-root user:

Create a sudo-enabled minecraft user
adduser minecraft
usermod -aG sudo minecraft

Set up SSH keys (more secure than passwords):

Generate and install an SSH key for minecraft
ssh-keygen -t ed25519 -C "minecraft-server"
ssh-copy-id minecraft@your_server_ip

Test the new account in a second terminal:

Connect to the VPS as minecraft
ssh minecraft@your_server_ip

Disable root login:

Edit the OpenSSH server configuration
sudo nano /etc/ssh/sshd_config

Change these lines:

Disable root login and password authentication
PermitRootLogin no
PasswordAuthentication no

Restart SSH:

Restart the OpenSSH daemon
sudo systemctl restart sshd

Test your sudo user login in a second terminal before logging out of root.

System updates and essential packages

Update all packages:

Update Ubuntu packages and reboot
sudo apt update
sudo apt upgrade -y
sudo reboot

Wait two minutes, then reconnect. Set timezone for consistent logs:

Set the server timezone to UTC
sudo timedatectl set-timezone UTC

Install required packages:

Install Minecraft administration tools
sudo apt install screen wget curl jq ufw fail2ban unattended-upgrades pigz -y

Firewall configuration

Configure UFW:

Configure UFW for SSH and Minecraft
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow 22/tcp comment 'SSH'
sudo ufw limit 25565/tcp comment 'Minecraft'
sudo ufw enable

The limit rule provides rate-limiting protection against connection floods and automatically applies to both IPv4 and IPv6.

Note: If adding other services later (web panel, voice chat), you'll need to allow their ports.

Verify status:

Show detailed UFW status
sudo ufw status verbose

Automated security

Enable automatic security updates:

Configure unattended Ubuntu upgrades
sudo dpkg-reconfigure -plow unattended-upgrades

Select "Yes" when prompted.

Enable fail2ban:

Enable and start Fail2Ban
sudo systemctl enable fail2ban
sudo systemctl start fail2ban

Installing Java

Minecraft requires Java to run. Different versions need specific Java versions.

Minecraft version Required Java
1.21.x Java 21 LTS or Java 23+
1.20.5-1.20.6 Java 21 LTS
1.20.1-1.20.4 Java 17 LTS
1.18-1.19.x Java 17 LTS
1.17.x Java 16
1.12-1.16.5 Java 8

Install Java 21:

Install the Java 21 headless runtime
sudo apt install openjdk-21-jre-headless -y

Verify installation:

Show the installed Java version
java -version

For older Minecraft versions, install openjdk-17-jre-headless or openjdk-8-jre-headless instead.

Note: Java 21 LTS is the current standard for Minecraft 1.21.x servers. Java 23 is also supported and stable, but Java 21 is recommended for long-term stability. Never use Java 22 as it is a non-LTS release.

Downloading server software

Different server software offers different features and performance.

Server software options

  • Vanilla: Official Mojang server software. Pure vanilla experience, baseline performance.
  • Paper (recommended): 40-80% better performance than vanilla plus plugin support. Most public servers use Paper.
  • Folia: Paper's multi-threaded fork. Best for 100+ player servers with compatible plugins.
  • Purpur: Popular Paper fork with extra gameplay features and configuration options.
  • Fabric: Mod support with performance similar to vanilla.
  • Forge: Large mod ecosystem but heavier than Fabric; both support modern versions.
  • Geyser/Floodgate: Allows Bedrock Edition players (mobile/console) to join Java servers. Download separately from Geyser and install in the plugins folder.

Creating server directory

Create and enter the Minecraft server directory
mkdir -p ~/minecraft_server
cd ~/minecraft_server

Downloading server files

For Paper (recommended):

Download the latest Paper build for Minecraft 1.21.10
VERSION="1.21.10"
BUILD=$(curl -s "https://api.papermc.io/v2/projects/paper/versions/${VERSION}" | jq -r '.builds[-1]')
wget "https://api.papermc.io/v2/projects/paper/versions/${VERSION}/builds/${BUILD}/downloads/paper-${VERSION}-${BUILD}.jar" -O server.jar

Verify download:

Inspect the downloaded Paper server archive
ls -lh server.jar

You should see a file around 40-50MB.

Creating an optimized start script

Create your start script:

Edit the Minecraft start script
nano start.sh

For servers with 4-6GB RAM (G1GC)

These flags are optimized for Java 21. If using different Java versions, consult the current JVM documentation.

Attempt to start Paper with G1GC tuning
#!/bin/bash
java -Xms4G -Xmx4G 
  -XX:+UseG1GC 
  -XX:+ParallelRefProcEnabled 
  -XX:MaxGCPauseMillis=200 
  -XX:+UnlockExperimentalVMOptions 
  -XX:+DisableExplicitGC 
  -XX:+AlwaysPreTouch 
  -XX:G1NewSizePercent=30 
  -XX:G1MaxNewSizePercent=40 
  -XX:G1HeapRegionSize=8M 
  -XX:G1ReservePercent=20 
  -XX:G1HeapWastePercent=5 
  -XX:G1MixedGCCountTarget=4 
  -XX:InitiatingHeapOccupancyPercent=15 
  -XX:G1MixedGCLiveThresholdPercent=90 
  -XX:G1RSetUpdatingPauseTimePercent=5 
  -XX:SurvivorRatio=32 
  -XX:+PerfDisableSharedMem 
  -XX:MaxTenuringThreshold=1 
  -jar server.jar nogui

For servers with 8GB+ RAM (ZGC, recommended for Java 21+)

ZGC requires Java 17 or higher. Java 21 or newer is recommended for best performance.

Attempt to start Paper with ZGC tuning
#!/bin/bash
java -Xms8G -Xmx8G 
  -XX:+UseZGC 
  -XX:+ZGenerational 
  -XX:+DisableExplicitGC 
  -XX:+AlwaysPreTouch 
  -XX:+ParallelRefProcEnabled 
  -jar server.jar nogui

ZGC reduces lag spikes from 100+ milliseconds to under 1 millisecond on servers with 8GB+ RAM. ZGC uses 10-15% more RAM than G1GC but provides much smoother performance. Keep this memory overhead in mind when allocating RAM.

Note: ZGC is recommended for servers with consistent high player counts (15+ concurrent players). For smaller servers (1-10 players), G1GC with the above flags will provide excellent performance with lower memory overhead.

Note: Java 23 and newer enable ZGenerational by default, so the flag is optional for Java 23+. For Java 21 and 22, always include the ZGenerational flag for optimal performance.

For ZGC, keep Xms equal to Xmx because ZGC handles memory allocation differently and performs best with equal values. For G1GC on Java 21+, set Xms to 50-75% of Xmx. For Java 17 and below, set Xms equal to Xmx.

Never allocate more than 80% of your total system RAM.

Make the script executable:

Make the Minecraft start script executable
chmod +x start.sh

Accepting the EULA

Run your start script once:

Run the Minecraft start script once
./start.sh

The server creates files, then stops. Edit eula.txt:

Edit the Minecraft EULA file
nano eula.txt

Change eula=false to eula=true then save.

Setting up as a system service

Create a service file:

Create the Minecraft systemd unit file
sudo nano /etc/systemd/system/minecraft.service

Add this configuration:

Define the Minecraft systemd service
[Unit]
Description=Minecraft Server
After=network.target
[Service]
Type=simple
User=minecraft
WorkingDirectory=/home/minecraft/minecraft_server
ExecStart=/home/minecraft/minecraft_server/start.sh
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target

Reload systemd and enable the service:

Reload enable start and inspect Minecraft
sudo systemctl daemon-reload
sudo systemctl enable minecraft
sudo systemctl start minecraft
sudo systemctl status minecraft

You should see "active (running)" in green.

Managing the service

View live logs:

Follow the Minecraft service journal
sudo journalctl -u minecraft -f

Restart the server:

Restart the Minecraft service
sudo systemctl restart minecraft

Stop the server:

Stop the Minecraft service
sudo systemctl stop minecraft

Configuration

Stop the server first:

Stop Minecraft before editing its configuration
sudo systemctl stop minecraft

Edit server.properties:

Edit Minecraft server.properties
nano server.properties

Key settings:

Configure Minecraft gameplay network and performance
## Network
server-port=25565
max-players=20
## Gameplay
difficulty=normal
gamemode=survival
pvp=true
hardcore=false
enforce-secure-profile=true    # Requires valid Mojang/Microsoft accounts
## Performance
view-distance=12
simulation-distance=8
network-compression-threshold=512
## Security
enable-command-block=false
white-list=false

Save changes and restart:

Start Minecraft after configuration changes
sudo systemctl start minecraft

Paper configuration

Paper 1.20+ uses config/paper-global.yml and config/paper-world-defaults.yml. Default settings are highly optimized. For advanced tuning, see the Paper configuration documentation.

Edit spigot.yml to reduce entity processing range:

Edit the Paper spigot.yml configuration
nano spigot.yml

Set entity-activation-range for animals and monsters to 48 and mob-spawn-range to 6.

Player management

Make operators in console:

Grant operator status to one Minecraft player
op PlayerName

Enable whitelist:

Enable the whitelist and add one player
whitelist on
whitelist add PlayerName

Network configuration

Port forwarding (home hosting only)

Access your router's admin panel at one of these common IPs: 192.168.1.1, 192.168.0.1, 10.0.0.1, or 192.168.2.1.

Create a port forwarding rule:

  • Service Name: Minecraft
  • External Port: 25565
  • Internal Port: 25565
  • Internal IP: Your server's local IP (find with ip addr)
  • Protocol: TCP and UDP

For home hosting: Consider Dynamic DNS (DuckDNS, No-IP) if your ISP changes your IP regularly.

Testing your connection

Find your public IP:

Show the VPS public IP address
curl ifconfig.me

Check the port with the MCToolBox port checker.

IPv6 configuration

Leave server-ip= blank in server.properties to auto-enable IPv4 and IPv6.

Verify IPv6 is listening:

Check which process listens on port 25565
sudo ss -tlnp | grep 25565

You should see entries showing both 0.0.0.0:25565 (IPv4) and :::25565 (IPv6).

Share your public IP with players to connect.

Connecting to your server

Launch Minecraft Java Edition. Ensure you're using the same version your server runs.

Click "Multiplayer" then "Add Server."

Enter:

  • Server Name: Any name you choose
  • Server Address: Your server's IP

Click "Done" to save. Green connection bars indicate success. Click the server to connect.

Need VPS resources for a Minecraft server?

Run Minecraft on Virtarix VPS infrastructure with root access, predictable CPU/RAM, NVMe storage, snapshots, backups, and room for players and worlds.

Troubleshooting

Connection timed out

Verify your firewall settings with sudo ufw status. Check if the server is running with sudo systemctl status minecraft. Test port accessibility with the MCToolBox port checker.

Wrong Java version

Error: Unsupported class file major version 65

Install Java 21:

Reinstall the Java 21 headless runtime
sudo apt install openjdk-21-jre-headless -y

Out of memory

java.lang.OutOfMemoryError: Java heap space

Increase Xmx in start.sh or reduce player count.

Performance issues

Check TPS in the console with /tps (20 = perfect, below 15 = lag).

Install Spark profiler for detailed analysis:

Download the latest Spark profiler plugin
mkdir -p ~/minecraft_server/plugins
cd ~/minecraft_server/plugins
wget https://ci.lucko.me/job/spark/lastSuccessfulBuild/artifact/spark-bukkit/build/libs/spark-bukkit.jar

Restart the server, then use /spark profiler in-game.

For advanced ZGC performance monitoring, add this to your start script:

Enable rotating JVM garbage-collection logs
-Xlog:gc*:file=gc.log:time,uptime:filecount=5,filesize=10M

Maintenance

Automated backup system

Create a backup script:

Edit the Minecraft backup script
nano ~/backup-minecraft.sh

Add:

Back up Minecraft worlds and rotate old archives
#!/bin/bash
SERVER_DIR="/home/minecraft/minecraft_server"
BACKUP_DIR="/home/minecraft/backups"
MAX_BACKUPS=7
mkdir -p "$BACKUP_DIR"
if systemctl is-active --quiet minecraft; then
    sudo systemctl stop minecraft
    sleep 5
fi
DATE=$(date +%Y-%m-%d_%H-%M-%S)
BACKUP_FILE="$BACKUP_DIR/backup_$DATE.tar.gz"
if command -v pigz &> /dev/null; then
    tar -cf - -C "$SERVER_DIR" world world_nether world_the_end server.properties ops.json whitelist.json | pigz > "$BACKUP_FILE"
else
    tar -czf "$BACKUP_FILE" -C "$SERVER_DIR" world world_nether world_the_end server.properties ops.json whitelist.json
fi
sudo systemctl start minecraft
find "$BACKUP_DIR" -name "backup_*.tar.gz" -mtime +$MAX_BACKUPS -delete
echo "$DATE - Backup created: $BACKUP_FILE ($(du -h "$BACKUP_FILE" | cut -f1))" >> "$BACKUP_DIR/backup.log"

Make executable:

Make the Minecraft backup script executable
chmod +x ~/backup-minecraft.sh

Schedule daily backups:

Edit the current user's crontab
crontab -e

Add:

Schedule the Minecraft backup for 04:00 daily
0 4 * * * /home/minecraft/backup-minecraft.sh

Adjust MAX_BACKUPS based on backup frequency (7 for daily, 4 for weekly).

Restoring from backup

Stop server:

Stop Minecraft before restoring a backup
sudo systemctl stop minecraft

Extract backup:

Extract a Minecraft backup over the server directory
cd ~/minecraft_server
tar -xzf ~/backups/backup_YYYY-MM-DD_HH-MM-SS.tar.gz

Start server:

Start Minecraft after a restore
sudo systemctl start minecraft

Server updates

Stop the server:

Stop Minecraft before updating Paper
sudo systemctl stop minecraft

Backup current version:

Back up the current Paper server JAR
cp ~/minecraft_server/server.jar ~/minecraft_server/server.jar.backup

Check plugin compatibility in the Paper downloads before major version updates.

Download new version:

Download the latest Paper build for Minecraft 1.21.10
cd ~/minecraft_server
VERSION="1.21.10"
BUILD=$(curl -s "https://api.papermc.io/v2/projects/paper/versions/${VERSION}" | jq -r '.builds[-1]')
wget "https://api.papermc.io/v2/projects/paper/versions/${VERSION}/builds/${BUILD}/downloads/paper-${VERSION}-${BUILD}.jar" -O server.jar

Start the server:

Start Minecraft after the Paper update
sudo systemctl start minecraft

Monitor for errors:

Follow Minecraft logs after updating Paper
sudo journalctl -u minecraft -f

If problems occur, restore the backup:

Restore the previous Paper JAR and restart Minecraft
cp ~/minecraft_server/server.jar.backup ~/minecraft_server/server.jar
sudo systemctl restart minecraft

Regular maintenance

Run weekly:

Update Ubuntu and review disk space and Minecraft errors
sudo apt update && sudo apt upgrade  # System updates
df -h  # Check disk space
sudo journalctl -u minecraft --since "7 days ago" | grep ERROR  # Check errors

Verify automatic updates are working:

Show the unattended-upgrades service status
sudo systemctl status unattended-upgrades

Conclusion

You now have a production-ready Minecraft server with optimized JVM settings, automated backups, and proper security. Keep your server updated for security and performance. Monitor resource usage through logs and address performance issues before they affect players.

Install plugins from Hangar or Modrinth to extend functionality. Start with friends, learn the systems, then expand as you gain experience.

Ready to host a Minecraft server on Virtarix VPS?

Compare VPS sizes for Minecraft servers with predictable CPU/RAM, NVMe storage, IPv4 + IPv6, root access, snapshots, and backups.

VPS S

For small sites, dev servers and Docker

$ 5 .50 /month
  • 3 cores
  • 6 GB
  • 50 GB NVMe
  • Unlimited
Get It Now
BEST SELLER

VPS M

For growing apps, websites and staging

$ 11 .40 /month
  • 6 cores
  • 16 GB
  • 100 GB NVMe
  • Unlimited
Get It Now
Peter French
About the Author Peter Frenchis the Managing Director at Virtarix, with over 17 years in the tech industry. He has co-founded a cloud storage business, led strategy at a global cloud computing leader, and driven market growth in cybersecurity and data protection.