Running a Minecraft Java 1.21.4 server for friends takes about ten minutes if you follow the steps in order. The part most guides skip is port forwarding — and that's the step that determines whether anyone outside your local network can actually connect.
This guide covers everything: the server jar, the startup script, the settings that matter, port forwarding, and when it makes more sense to use a dedicated host instead.
What you need
- A PC running Windows, macOS, or Linux
- Java 21 — required for Minecraft 1.21+. Download from Adoptium if you don't have it. Verify with
java -versionin a terminal. - A stable internet connection (upload speed matters — 1 Mbps per player minimum, 2+ recommended)
- About 4–8 GB of free RAM for the server process
For more than 5 players, or for modded packs, you should use a dedicated server host. See the hosting comparison guide for options. Self-hosting is practical for 2–5 friends on a vanilla or lightly modded setup.
Step 1 — Download the server jar
Go to minecraft.net/en-us/download/server and download the official 1.21.4 server jar. It's a single file: server.jar (approximately 50 MB).
Do not download "server jars" from third-party sites. The official URL is the safe source.
Create a dedicated folder for your server — e.g., C:\MinecraftServer\ or ~/minecraft-server/. Place server.jar inside it.
Step 2 — Accept the EULA
Run the server once to generate required files:
java -jar server.jar nogui
The server will exit immediately and create a file called eula.txt. Open it and change:
eula=false
to:
eula=true
This is legally required — you're confirming you've read Mojang's End User License Agreement.
Step 3 — Create a startup script
Instead of typing the full java command every time, create a script.
Windows — create start.bat:
@echo off
java -Xmx4G -Xms2G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:InitiatingHeapOccupancyPercent=15 -jar server.jar nogui
pause
macOS / Linux — create start.sh:
#!/bin/bash
java -Xmx4G -Xms2G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:InitiatingHeapOccupancyPercent=15 -jar server.jar nogui
On Linux/macOS, make it executable: chmod +x start.sh
RAM allocation guide:
| Players | Setup | -Xmx value |
|---|---|---|
| 2–4 | Vanilla | 2G–3G |
| 2–5 | Vanilla + a few mods | 3G–4G |
| 5–10 | Vanilla or light mods | 4G–6G |
| 10+ | Vanilla | 6G–8G |
| Any | Large modpack | 6G–12G |
The JVM flags after -Xmx are Aikar's tuned GC settings — they significantly reduce freeze-stutters from garbage collection. Use them as-is.
Step 4 — Configure server.properties
After the first successful launch (which generates the world and all config files), open server.properties. The settings that meaningfully affect player experience:
# Core settings
server-port=25565
gamemode=survival
difficulty=normal
max-players=20
online-mode=true
# Performance — adjust these carefully
view-distance=10
simulation-distance=8
entity-broadcast-range-percentage=100
# World
level-name=world
level-seed=
level-type=minecraft:normal
spawn-protection=16
allow-nether=true
Critical settings explained:
view-distance — how many chunks the server sends to each client. Default 10. Lower = better TPS, worse visual distance. For 1–5 players you can run 12–16 comfortably. For 10+ players on shared hardware, drop to 8–10.
simulation-distance — how many chunks around each player actively tick. Default 10. This is the main TPS lever. Dropping from 10 to 8 reduces active chunks by ~36%. Keep it high enough to cover player activity (farms, builds) but no higher.
online-mode=true — requires players to have a purchased Minecraft account. Set to false only if you're using a proxy or running a local LAN server with players on the same network. Never set to false on a public server.
spawn-protection — radius around spawn that only ops can modify. Set to 0 if you want players to build freely near spawn.
Step 5 — Port forwarding
This is where most self-hosting setups fail. Port forwarding tells your router to send incoming Minecraft connections (port 25565) to your server PC.
Step by step:
- Find your router's admin page — usually
192.168.1.1or192.168.0.1in a browser - Log in (check the sticker on your router for default credentials)
- Find the section called "Port Forwarding", "Virtual Server", or "NAT"
- Create a new rule:
- External Port:
25565 - Internal Port:
25565 - Protocol:
TCP(some routers let you choose TCP+UDP — that's fine too) - Internal IP: your server PC's local IP (find it with
ipconfigon Windows orifconfigon macOS/Linux — look forIPv4 Addressstarting with192.168.x.x)
- External Port:
- Save and apply
Finding your public IP (what friends connect to): go to whatismyip.com from any browser on your network. Share this address with your friends.
Your public IP may change when your router restarts (most home connections use dynamic IPs). If friends can't connect after your router rebooted, check if your IP changed. A free service like No-IP provides a hostname that tracks your changing IP — more reliable for regular sessions.
If you're on a university network, corporate network, or strict ISP: port forwarding may not be possible. In that case, use Playit.gg (free tunnel for Minecraft) or a dedicated host.
Step 6 — Add yourself as operator
In the server console (not in-game), type:
op YourMinecraftUsername
Operators can use cheats, run commands, bypass spawn protection, and manage the server while connected as a player.
Step 7 — Performance mods for servers
The vanilla server jar is unoptimized. Install Paper or add Fabric + performance mods to meaningfully improve TPS.
Option A: Switch to Paper (easiest)
Paper is a drop-in replacement for the vanilla server jar. It improves multi-threaded chunk handling, entity activation, and includes hundreds of optimizations by default. Download from papermc.io, rename to server.jar, restart.
Paper is compatible with most vanilla plugins but not Fabric mods.
Option B: Fabric + mods (for mod support)
If you want Fabric mod support, install the Fabric server jar instead of vanilla, then add:
- Lithium — game logic optimizations
- Krypton — network stack improvements
- Fabric API — required by both
See the complete performance mod guide for the full list.
When to use a dedicated host instead
Self-hosting on a home PC makes sense for:
- 2–5 players, occasional sessions
- Testing a modpack before committing to a paid host
- When you're always running the server PC anyway
Consider a dedicated host when:
- More than 5 regular players
- You want 24/7 uptime without leaving your PC on
- Your home internet upload is below 10 Mbps
- You want automated backups and a control panel
The SyntaxMine hosting comparison covers BisectHosting, Apex Hosting, Shockbyte, and ScalaCube with pricing, performance, and mod support details.
Basic management commands
Once the server is running, manage it from the console or in-game as an operator:
stop # graceful shutdown
save-all # force world save
whitelist on # enable whitelist (only listed players can join)
whitelist add PlayerName # add to whitelist
ban PlayerName # ban a player
kick PlayerName # kick without ban
gamemode survival PlayerName # change a player's gamemode
tp PlayerName1 PlayerName2 # teleport
Resources:
- Official Minecraft server download: https://www.minecraft.net/en-us/download/server
- Java 21 (Adoptium): https://adoptium.net
- Paper server: https://papermc.io
- Port forwarding guides per router model: https://portforward.com/minecraft
- Playit.gg (if port forwarding isn't available): https://playit.gg
- SyntaxMine hosting comparison




