Tutorial: Setting up a Java Edition server
This tutorial takes you through the steps of setting up your own Java Edition server using the default server software that Mojang Studios distributes free of charge. The software may be installed on most operating systems, including Windows, macOS, and Linux. For a tutorial about installing Bedrock Edition server software, see Tutorial:Setting up a Bedrock Edition server.
Preface
A Minecraft server provides a game environment for players to play multiplayer with others connected through the Internet or a local area network (LAN). Players are connected to a server using the Minecraft client software, and the server hosted using the server software.
This tutorial is meant to show and explain the basics and recommendations of setting up a Minecraft server, from installing Java, to configuring and publishing the Minecraft server itself. Setting up a server takes some time, and some technical knowledge. Take time to research any concepts you found unsure or uncertain before or while reading this tutorial.
User knowledge
In order to run your server correctly, we highly suggest that you should at least know about the following:
- Technical game knowledge, such as commands, chunk, etc.
- Using the command-line and editing configuration files
- Networking in general (IP, ports, etc.)
- System configuration
System and performance
The performance of your Minecraft server can be influenced by many factors, but the two key elements that commonly affect all servers are the player count and the world size. The higher these numbers, the more hardware power you will need.
It depends on your player base's play styles, but each player can affect your server's resource:
- The server must simulate a part of the world around them, this includes processing entities, redstones, chunk generation, and more;
- A player can generate new chunks and build structures, from small houses to cities, these can grow your world's size;
- Any active player-made structures, such as redstone machine, mob farms, etc. can be resource intensive.
Typically, a survival server with 4–8 players can run on most modern hardware.
CPU
Most modern CPUs should suffice for a small to medium size server. For reference, starting with budget Intel 8th gen or Ryzen 2000 series CPU is good enough for small servers. Note that Minecraft servers mostly utilize a single core. If your server grows larger, you should ideally find a CPU with high single-thread performance.
RAM
Depending on your size of the world, you would need more RAM memory to run the server. For small servers, it is recommended that you have at least 2 GB of RAM available. It is very possible that you need 4 GB of RAM for larger servers.
Storage
Your Minecraft world can grow large over time, so make sure to reserve at least 5GB of disk space for it.
Networking
Minecraft server need a stable internet connection. For this reason, Wi-Fi is not recommended. You typically won't need to worry about the bandwidth unless you run a large server. To make sure you have a low and consistent ping, it is recommended that your server's physical location be as close to your players as possible.
Other
You don't need extra hardware to run a server, including a GPU.
You can learn more about the system requirements to run a server on the Server/Requirements page.
Hosting services
If you still want to manage a server, but not from home, you might want to look for Minecraft server hosting services, which provide a machine and sometime a quick way to setup your Minecraft server. Expect to pay monthly for this type of server since finding free hosting is a rarity, but you save the hassle of constantly maintaining a server and ensure it is always online for your players.
Alternatively, you can pay for Realms, the official subscription-based server hosting service by Mojang Studios (although comes with limitations unlike a normal server).
Other ways of playing multiplayer
If you want to setup a quick and simple multiplayer server in your home, check out the Tutorial:Setting up a LAN world. Note that players must be connected to the same local network, usually in the same network from Wi-Fi or router.
If you decide you don't want to host, but still want to play online, check out the public server options on the official server listing by GamerSafer.
There is also custom server software available, which most large servers use, but these applications are not supported by Mojang Studios. Notable custom server software being SpigotMC and PaperMC, and if using mods, you can run Forge and Fabric servers.
Java

Java is a programming language designed to create programs for the Java Virtual Machine (JVM). The JVM supports many different platforms. By doing this, developers write code for the JVM and any platform supported by the JVM can run the program.
OpenJDK distribution
There are several OpenJDK distributions out there, with the most popular one being Adoptium's OpenJDK Temurin. Alternatively, Microsoft also offers their own build of OpenJDK. It is the Java build bundled with the Minecraft Launcher, and is available for commercial purposes.
JRE is all you need
JRE stands for Java Runtime Environment. JRE is a package tool designed to run Java programs. JDK is a package of tools designed to develop Java programs. If you have the JDK then you have the JRE and the JVM too. Minecraft server only needs JRE, the full JDK package is not required.
Use headless Java if you don't work with a GUI
A headless Java installation is a trimmed down version of Java. It does not have a GUI or mouse/keyboard support and its less resource intensive. Headless Java is frequently used in servers or other environments where a GUI is not needed.
| “ |
|
„ |
| — Debian Wiki |
Newer versions of the game need newer Java versions
Some versions of Minecraft: Java Edition server require a minimum Java version in order to be run on. Here are several Java version requirements for Minecraft server:
- Minecraft ≥ 1.20.5 and 1.21 requires Java 21.
- Minecraft ≥ 1.18 requires Java 17.
- Minecraft ≥ 1.12 requires Java 8.
For the full list of Java version requirement of Minecraft: Java Edition, please visit Tutorial:Update Java § Why update?
Older versions of Minecraft can run on newer Java, for example, Minecraft 1.16 can run on Java 17, Minecraft 1.18 can run on Java 20, and etc.
Java installation
The Minecraft server requires the Java Runtime Environment (JRE). Downloading and installing the Java Development Kit (JDK) features a complete set of utilities and tools made for Java, that includes the JRE too, so if you were to install JDK, JRE is always included.
For your security, you should only use the latest version of Java supported by the game. The latest version of Java supported by Minecraft: Java Edition (≥ 1.20.5 and 1.21) is Java 21.
Windows
To verify that you have the latest version, do one of the following:
- Download Java Uninstall Tool. The software will check for your installed Java version, and removes older Java installation if necessary.
- Open Windows Command Prompt, and run the command
java -version. If a version number is reported, see Tutorials/Update Java § Why update? for the latest Java version for your Minecraft server.
If you don't have Java or your version is outdated, then you can download Adoptium's OpenJDK Temurin or Microsoft build of OpenJDK.
Winget
Winget is the official Windows package manager for installing programs from Microsoft Store and the Winget repository. It is included in Windows 10 and Windows 11 by default.
You can install multiple OpenJDK distributions using Winget. Since Minecraft server only requires JRE, it is optional to install the full JDK package. You can choose either Temurin or Microsoft build of OpenJDK:
winget install EclipseAdoptium.Temurin.21.JREfor Adoptium Temurin 21 JRE-only.winget install Microsoft.OpenJDK.21for Microsoft build of OpenJDK 21.
macOS
OpenJDK can be installed using Homebrew package manager for macOS:
- Open the terminal.
- Check if you have Java by running
java -version. - If you don't have Java, or need to install specific version, you can install it via Homebrew:
- Run
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"to install Homebrew first. - Run
brew install --cask temurin@21to install Adoptium Temurin 21.
- Run
- Run
java -versionagain to see your Java version.
Keep in mind that Temurin 21 requires macOS version 10.11 or greater, or the server wont run correctly.
Linux distributions
Linux comes in many different variation called distributions (distros). Some of these distros are designed or better suited for running a server. If you are setting up a dedicated server it is recommended to use one of these distros.
Linux in general is more favorable to open source programs. So where applicable it is recommended you use open source programs, such as OpenJDK.
Ubuntu, Raspbian, Debian-based
OpenJDK can be installed by using apt:
- Before installing, it is recommended to run
sudo apt update. sudo apt install openjdk-21-jdk-headlessfor OpenJDK 21.sudo apt install openjdk-8-jdk-headlessfor OpenJDK 8.
Removing the -headless part of the command will install GUI components of Java.
Fedora, AlmaLinux, Rocky Linux, CentOS, RHEL-based
OpenJDK can be installed using dnf:
sudo dnf install java-21-openjdk-headlessfor OpenJDK 21.sudo dnf install java-1.8.0-openjdk-headlessfor OpenJDK 8.
Removing the -headless part of the command will install GUI components of Java.
openSUSE
OpenJDK can be installed by using zypper:
sudo zypper install java-21-openjdkfor OpenJDK 21.sudo zypper install java-1_8_0-openjdkfor OpenJDK 8.
It is recommended to use openSUSE Leap rather than rolling-release Tumbleweed for server stability.
Arch Linux
OpenJDK distributions are available on Arch Linux repository.
OpenJDK can be installed by using pacman:
pacman -S jre21-openjdk-headlessfor OpenJDK 21.pacman -S jre8-openjdk-headlessfor OpenJDK 8.
Removing the -headless part of the command will install GUI components of Java.
If you encounter issues, it is recommended that you refer to the official Arch Linux Wiki (see also Minecraft/Java Edition server).
Gentoo
Run emerge --ask virtual/jdk. This will install OpenJDK according to your profile.
For older versions of Java refer to Gentoo Wiki.
Other distributions
Check your distro's documentation. It should have information on how to install OpenJDK.
Alternatively, you can visit Java's website directly to download the Java package for Linux. Most distros work with this (either 32 or 64-bit). Instructions for the installation of those different packages are given on the site.
FreeBSD
OpenJDK can be installed in FreeBSD using pkg:[1]
pkg install openjdk21for OpenJDK 21.pkg install openjdk8-jrefor OpenJDK 8 JRE-only.
Once you have installed OpenJDK, you may see OpenJDK requires fdescfs and procfs. In order to satistfy this requirements, you can run the following commands:
mount -t fdescfs fdesc /dev/fdforfdescfsmounted on/dev/fd.mount -t procfs proc /procforprocfsmounted on/proc.
This changes are not permanent on the next system reboot. In order to make them permanent, you need to add these mountpoints to your /etc/fstab file. Open them with your text editor (such as nano or vi) and insert the following lines into /etc/fstab:
# device-spec mount-point fs-type options dump fdesc /dev/fd fdescfs rw 0 0 proc /proc procfs rw 0 0
Lastly, you will want to rehash to be sure that you can use your new Java binaries immediately, run rehash in the command line.
For installing OpenJDK using ports instead, please visit this website for more information. Packages from pkg are compiled binaries of the ports.[2]
Docker
Docker is a free container based platform which helps to isolate instances of a Minecraft server from each other, and from the host system. You can get Docker from the official documentation website.
The Docker image we are using for the tutorial is itzg/minecraft-server, which provides the latest and up-to-date Java Edition server:
- Create a directory for the container.
- Write the contents below to a file called
docker-compose.yml:services: mc: image: itzg/minecraft-server tty: true stdin_open: true ports: - "25565:25565" environment: EULA: "TRUE" volumes: # attach the relative directory 'data' to the container's /data path - ./data:/data
- Start the container (and the Minecraft server) by running
docker compose up -din that directory. - Once the server started, the server IP address should be your host's internal IP address with the default port of
25565. See § Publishing the Minecraft server in the Local Area Network section for setup guidelines.
For updating the Minecraft server later in the future:
- Run
docker pull itzg/minecraft-server itzg/minecraft-server:<tag>in the same directory, where<tag>is the specific Minecraft version you want to update to. - Run
docker compose down, thendocker compose up -dto apply the update.
Running the Minecraft server
The general gist of running a Minecraft server is that you will need to install java, run the server, accept the EULA, and run it again. Once you have installed java and opened up a command line, everything is basically the same.
- Check the system requirements for CPU, RAM, and disk space.
- Install Java from the § Java installation section.
- Download your server.jar file from the official download page. Rename the downloaded file to "server.jar" for easy reference later in the tutorial.
- Make a new folder for the server.jar file and move it there. This will be where all the configuration and the world files will be stored, so you don't want these to just sit in the downloads folder.
- Open Windows Command Prompt or a command-line interface.
- Type
cd(stands for "change directory"), followed by the path to the folder where you placed your server.jar file. You can drag the folder into the command-line window to get the path, if you have a GUI open. - Run the server for the first time by typing
java -jar server.jar --nogui. - A file called
eula.txtwill be generated after you run the server for the first time. Open it in a text editor and changeeula=falsetoeula=true. It signifies that you have read and understood the End User License Agreement that you'll follow when using the software. If you don't do this, the server will shut down immediately when you try to start it. - Now the server has been set up, and you can simply run it with
java -jar server.jar. If you don't want a GUI for typing commands, add a space and--noguito the command. You can also use a few other switches described below.
Startup script
At this point you should have a basic server running. One of the things you definitely want to do is write a startup script to launch your Minecraft server, so you don't have to rewrite it again for every time you launch it.
Windows
Windows uses batch file to run series of commands on the command line.
Create a text file in the folder where you put the jar as "start.bat", and write the following in:
@ECHO OFF
java -Xms1024M -Xmx2048M -jar server.jar --nogui
pause
Save the file, and double click it to start your server.
The "pause" command is there to keep the window open so you can read what happened after the server stops. The -Xms1024M and -Xmx2048M options set your minimum and maximum memory respectively for your server. See § Java options for futher information.
macOS, Linux, and FreeBSD
Most systems that are POSIX-compliant can write and run shell scripts. Shell scripts typically end with ".sh" filename extension.
Create a text file in the folder where you put the jar as "start.sh" and write the following in:
#!/bin/sh
cd "$(dirname "$0")"
exec java -Xms1024M -Xmx2048M -jar server.jar --nogui
Save the file, and run chmod a+x start.sh to make it executable. You can now run the file by double-clicking or by running ./start.sh in the folder.
If you want to add a pausing part like the Windows example, remove the exec word, and add a line of read -n 1 -p "Waiting..." to the end. This is useful if you are running the script by double-clicking on the GUI.
Third-party scripts and tools
Alternatively, you can manage and automate the startup and shutdown of the Minecraft server using scripts and tools listed below:
- Minecraft Server Control Script (MSCS) is a server-management script for UNIX and Linux powered Minecraft servers. Features include:
- Run multiple Minecraft worlds.
- Start, stop, and restart single or multiple worlds.
- Create, delete, disable, and enable worlds.
- Includes support for additional server types: Forge, BungeeCord, SpigotMC, etc.
- Automatically backup worlds, remove backups older than X days, and restart worlds.
- Visit the Minecraft Server Control Script Github page for more information.
- Minecraft Server Manager A comprehensive startup script for Minecraft and Bukkit servers (support Debian, such as Ubuntu).
- MSM can also periodically create World Edit compatible backups.
- Keeps players informed with configurable in-game messages, such as "Shutting down in 10 seconds!"
- Expose in-game commands (such as "say", "op" and "whitelist") to the terminal.
- Tab completion on all commands makes learning easy.
- Visit Minecraft Server Manager's GitHub page for the full list of features.
- Server startup script
- FreeBSD startup script
- OpenBSD startup script
- Ubuntu startup script
- Minecraft Systemd Service A fully systemd-integrated Minecraft service:
- Working on CentOS and Fedora
- Protecting the server with various readonly and inaccessible jails
- Safe restart and stop operations using rcon
- Can be combined with a Minecraft Command Center Script for ease of administration
- Arch Linux systemd wrapper
Configuring the Minecraft server
You can configure the server by editing the server.properties file, the format for which is explained on that article. Be certain to edit the file with a text editor that does not add formatting (e.g., for italics), such as Windows Notepad. Additional configuration may not be necessary as many servers run fine from the default values.
Operator list
To become or add an operator, type /op <targets> into the server console. This adds the specified user's username and UUID to the ops.json file. Operator status will not be changed if you change your username due to the use of UUID.
Administrators and operators may execute commands. In other words, operator privileges allow you to control certain aspects of the game (e.g., teleporting players).
- Example of
ops.jsoncontents
[
{
"uuid": "069a79f4-44e9-4726-a5be-fca90e38aaf5",
"name": "Notch",
"level": 4,
"bypassesPlayerLimit": false
}
]
Whitelist
Whitelist is a feature that allows and blocks specific players in a configured list to join the server. By default, this feature is disabled, but can be changed in the server.properties by setting white-list=true.
Configuring whitelist is easy, you can add a player to the list by typing /whitelist add <username> into the server console. You can also directly edit the whitelist.json file in the server directory by manually adding their username and UUID.
- Example of
whitelist.jsoncontents
[
{
"uuid": "069a79f4-44e9-4726-a5be-fca90e38aaf5",
"name": "Notch"
},
{
"uuid": "853c80ef-3c37-49fd-aa49-938b674adae6",
"name": "jeb_"
}
]
For offline servers (with online-mode disabled in server.properties), you need to add the player's offline UUID from their username in the whitelist.json file. You can get offline and online UUID from this calculator:
Java options
Java options should be added between the java and the -jar on the command line, or in your startup script.
- Memory limits
- The most important thing for a Minecraft server is memory to run with.
-Xmxdefines how much memory it is allowed to use.-Xmx2G(2 gigabytes) is more than enough for a home server with 5 players on default simulation distance (5×212 = 2205 chunks simulated), but do scale it up by your actual settings. Setting the value too low causes frequent GC stops. Making it too high can make GC too long on Java 8. -Xms(the initial memory size) is the next biggest knob, but only affects startup performance. If your server also runs things other than Minecraft, set it to 1/4 of the maximum size (so for our case,-Xms512M) for a good balance: the JVM will be allowed to return some memory to the OS when it's not needed. (The return algorithm is very conservative, so it has very minimal effect on long-term performance.) If your server is fully dedicated to Minecraft, feel free to go higher: making it equal to the maximum size disables heap scaling and gives maximum startup speed.- A "soft max heap size" (
-XX:SoftMaxHeapSize=1G) is available for some versions of JRE. The JRE will try to only use that much memory, but will go over to a maximum of-Xmxif necessary. If you are running many things on your server, this may be useful. - GC
- The default GC on Java 9+ used by modern Minecraft is G1GC (Java 8 also has it, but it is off by default). The flags used by the official Minecraft Launcher:
-XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32Mworks reasonably well, though of course better flags, like brucethemoose's Minecraft Performance Flags and Aikar's Garbage Collector flags exist. - On Java 14+, ZGC is available. This GC is almost lag-free with millisecond-level pauses. Delete all GC-related flags and simply use
-XX:+UnlockExperimentalVMOptions -XX:+UseZGC. Tuning flags other than-Xmxare a lot less important compared to in GCs (because the default is quite good), although-XX:-ZProactiveis worth a try if you want to trade memory for lag. - VM
- Calculations may be made faster with GraalVM, benefiting operations such as chunk generation. A basic version is bundled in the common "HotSpot" Java 9–15, but it was later removed due to maintenance burden. Now you need to download it separately: use instructions from brucethemoose.
To sum up, a reasonable flag combination can be as simple as -Xmx4G -Xms1G -XX:SoftMaxHeapSize=3G -XX:+UnlockExperimentalVMOptions -XX:+UseZGC. That is it. There are bits that you can squeeze from complicated flags, but you would get much more from modified server software. In fact, all serious discussions (e.g. Aikar and brucethemoose) of server performance assume some degree of modding.
Server options
The options for the server.jar are inserted after the java -jar server.jar part. Run with --help to see all available arguments that can be passed to the server.
Below is a table of available command-line options for the server:
| Option | Description |
|---|---|
| --bonusChest | Enable the bonus chest when generating a world for the first time. |
| --demo | Enable demo mode. Shows the players a demo pop-up, and players cannot break or place blocks after the 5 in-game days demo time has expired, even if they have purchased the game. |
| --eraseCache | Erase cached data like light levels and biome data, which must then be regenerated. Equivalent to the "Erase Cached Data" option of "Optimize World" in World Options on the client. |
| --forceUpgrade | Optimize the world by upgrading the level data to the latest format. Once the world is optimized, it is no longer compatible with older level formats. Equivalent to the "Optimize World" option in World Options on the client. |
| --help | Print available options without starting the server. |
| --initSettings | Initialize server.properties and eula.txt without starting the server. If either file is missing, it creates them with default values.
|
| --jfrProfile | Initialize Java Flight Recorder profiler for the server. While the server is running, the profiler can be opened using an external tool or software, such as VisualVM. It enables monitoring of the server's CPU, memory, and threads usage. Additionally, it saves a jfr file on the debug folder of the server.jar, containing JVM and operating system events, and several Minecraft-related custom events. Further information on Commands/jfr § Usage.
|
| --nogui | Disable GUI when launching the server. |
| nogui | Legacy alias of --nogui. |
| --pidFile <path> | Create a text file at path containing the process identifier (PID) of the server process while it's running. |
| --port <port> | Specify the TCP port to use instead of the value in server.properties.
|
| --recreateRegionFiles | Optimize the world similar to --forceUpgrade, but also rewrites all the chunks independently of whether they have been upgraded, creating a fresh and defragmented region files.[3] Using this option after changing region-file-compression in server.properties will recompress all region files in the new format.
|
| --safeMode | Ensure the server only loads the vanilla datapack. |
| --serverId <id> | Specify the "Server Id" string used in the crash report details. |
| --universe <path> | Specify the path to the directory level-name in server.properties is relative to. If empty, it is relative to the working directory.
|
| --world <name> | Specify the world name to use instead of the level-name value in server.properties.
|
The file generated by --pidFile can be used in command-line to stop the server itself, for example, using cat <path_to_pidfile> | xargs kill on most Linux systems.[4]
Example command line
- Running a world found in the folder "cold" on port 1337, with 1G of RAM allowed:
java -Xmx1G -jar server.jar --port 1337 --nogui --world cold.
Publishing the Minecraft server
After successfully configuring and starting up your Minecraft server, you now must publish your Minecraft server, so players can see and join your server through the Internet or locally.
There are several methods of publishing your Minecraft server:
Local Area Network
Local Area Network (LAN, or local network) is a computer network that is used to connect between devices and communications in a limited area, such as personal home, university campus, or office building. When your device is connected to your router, it is participating in the router's LAN, this includes other devices connected into the router. As such, using the LAN, you can connect and communicate to other devices or applications hosted on the network, such example is a Minecraft server. Computer network like LAN is usually considered a private network.
Each device in the network is given an unique identifier called IP address. When used in a LAN setting, these IP addresses are often referred to as internal IP address, as they belong to private IP ranges. Applications in these devices can listen for and send communications with other devices in the LAN through specific ports opened by their host devices.
When you start a Minecraft server on your device, the server requests a specific port number to the server host's operating system in order to communicate with other devices in the network. The host then assigns, and listens for all upcoming connections from the port, directing them to the Minecraft server to process. The default port for a Minecraft server is 25565, but can be configured in the server.properties file.
Players can connect to your server on LAN by inserting the server host's internal IP address followed by the port number. For example, if the server host's internal IP address is 192.168.1.2 and the port number is 25565, you would connect to the server using the address 192.168.1.2:25565.
Do remember that players need to participate in your LAN, if they aren't, they are unable to connect to your server locally. They can participate in your LAN by connecting their devices to the router via ethernet cable or wireless.
Getting the internal IP address
Getting your server host's internal IP address is important for connecting to your server in LAN. It is also used in port forwarding, specifying which internal IP and port for your router to port forwards to.
With that in mind, getting the internal IP address is easy:
Windows
- Press ⊞ Win + R; this should be up to the "Run" dialog box. Type
cmdand hit ↵ Enter. This should open a command window with a black background. From there, typeipconfigand press ↵ Enter. You should be given a list of text. Scroll up to "Wireless LAN" (if using wireless) or "Ethernet" (if using a wired connection), and look at "IPv4 address". To the right of this should be a string of numbers (of the form xxx.xxx.xxx.xxx). Copy this down by right-clicking the window and selecting "Mark", then highlight the area and hit Enter. Don't copy any parentheses or letters.
Linux
- Open the terminal, and run
ip address. The output will display all of your network interfaces. If you're using ethernet, you want start looking for the line that starts withethXorenpXsX, and for wireless,wlanXorwlpXsX. Notice the "X" on the device names, they usually indicate the bus and the slot number. Depending on your system configuration, the numbers may be different, but the first or second network interface on the list is usually the one connecting into your router. Find the internal IP address written next toinet, which will look likeinet xxx.xxx.xxx.xxx, copy thexxx.xxx.xxx.xxxnumbers down.
Port forwarding
Port forwarding is a special network configuration that redirects or forwards connections from an IP address and port number to another. This can be useful for a Minecraft server, as port forwading lets players connect to your server remotely, over long distance through the Internet.
When port forwarding on your router[a], you are forwarding connections coming from your external IP in the Internet to your server host's internal IP in the LAN, which in turn, allows players to connect to your Minecraft server by using your external IP.
With that in mind, here is the process on how to port forward your Minecraft server that should be applicable to most routers:
- Before port forwarding, do not forget to open a TCP/UDP port (default is 25565) on the server host's firewall.
- On Windows, if you launch your server for the first time, there will be a firewall prompt allowing "OpenJDK Platform binary" application to access public and private networks. If you allow it, then Windows will automatically manage the firewall rules for you.
- Visit your router administration page through an Internet browser. You can usually visit it via your router's internal IP address.
- The router's internal IP address is often called gateway address. On Windows, you can find it through
ipconfig, and find the IP address next toDefault Gatewaycolumn.
- The router's internal IP address is often called gateway address. On Windows, you can find it through
- Find your router's port fowarding settings.
- Create a port forwarding rule for your Minecraft server. In your router settings, it may be called "new service" or "new rule". If the router asks for the service/rule name, you may name it as you wish, or insert "minecraft" for simplicity.
- For internal IP input, insert the server host's internal IP address.
- For external IP input, leave it as is.
- For internal and external port input, insert your server's port. Minecraft server's default port is 25565. For the port type, choose "TCP/UDP" or "Both". If those aren't an option, then you have to create two rules for both protocols.
- ↑ If you have more than one routers, make sure your server host connects to the router that is directly connected to the Internet, and not from another router. Port forwarding from nested routers causes all connections to port forward to the parent router, in which case you must configure port forwarding on that one too.
Port forwarding notes
- The portforward.com website is a good source for address translation, opening the firewall and routing, and port forwarding. Select your router from that list, and you will see instructions for setting up port forwarding. Alternatively, you can read the documentation supplied with your router, modem, or other ISP related hardware.
- Verify the port is open, and note your external IP by using a port checker tool, such as You Get Signal. The default port you should test is 25565, unless you specified something else. Have the Minecraft server running when you test the port.
- You can obtain your external IP address from YouGetSignal.
Dynamic IP issues
If your internal or external IP changes, this means the current IP you have is a dynamic IP. This can cause problems to the port forwarding rules. Here are some workarounds and fixes you can do to resolve this issue:
- You should set a static internal IP for your server host machine. Most routers by default use DHCP, and in turn, the internal IP address assigned to your server can change, which can affect port forwarding rules, and make them invalid. Each modem or router has a different way of setting a static internal IP address. You should refer to the manual for your device(s) or online documentation for further instruction.
- Most Internet service providers only offer dynamic IP, and because of this, your external IP address may often change, typically every few days to few weeks. This may hinder or absolutely prevent port forwarding from working.
- Use a tool such as WanIP to periodically check on the external IP address. You may also search "my ip address" on Google and it will show your IP address.
- Alternatively, you can look into a dynamic DNS (DDNS) service that will allow you to have a name, rather than an IP address, that will remain the same. The name will point to your external IP address, regardless of whether or not it changes (the DNS is updated when changes occur, hence "dynamic").
- You can contact your Internet service provider for a static IP for your external IP address. They usually offer it for an additional monthly fee.
- For troubleshooting purposes you can try running Minecraft on the server machine and connect locally. You can connect through either
localhost, your internal IP (192.168.x.x) or your external IP. - If for some reason you have trouble with connecting publicly over your IPv4, try connecting over IPv6. This should only be done for testing whether your server is online, external players should still use IPv4.
Virtual Private Network
Virtual Private Network (VPN) can be used to let players connect to your server through a secure connection or a private network.
VPN simulates LAN connections between the players and the server over the Internet. Players can join a server hosted on the network by first connecting to the network via VPN software, and then accessing the server using the internal IP address provided by the VPN. This method serves as an alternative to port forwarding, which directly hosts and connects the server on the Internet.
However, this may be inconvenient for many players, as it typically requires everyone to download and install the same software the host uses in order to join the server.
There are three common VPN software you can use for connecting your Minecraft server: LogMeIn Hamachi, Radmin VPN, and ZeroTier. The following steps below are tutorial for setting up VPN for your server depending on the provider you use:
Hamachi
- Install Hamachi on each computer that wishes to participate in the server, including the host. Download Hamachi for Windows, Mac, or Linux[note 1].
- The host server signs up for admin via the LogMeIn website.
- On the host machine, a new Hamachi network is created.
- The host installs and configures the Minecraft server software. The
server-ipfield inserver.propertiesis left blank (as default). - The host passes the newly created Hamachi network credentials to each of the players.
- The players connect to the host's Hamachi network.
- Now that all the machines are connected within the same Hamachi network, the host gives their machine's Hamachi IPv4 address to the players.
- Each player connects using this IP as per the usual Minecraft multiplayer screen.
- ↑ 32-bit and 64-bit
.deband.rpmpackages are available. For Gentoo, you can install it by emerging "net-misc/logmein-hamachi".
Radmin VPN
- Download and install Radmin VPN
- Create a network: after Radmin VPN installation on the local computer press "Create network" button. Set a Network name and a Password → Press "Create" button.
- Now the new network will appear in the main window → invite friends, send them the info to connect → then run the Minecraft game.
- After program launch press "Join network". In the dialog box press enter name name and password received from the network administrator, then click "Join", and the new network and its nodes will be shown in the main window. Connect to the host in Minecraft.
ZeroTier
- Install ZeroTier One on each computer that wishes to participate in the server, including the host. Download ZeroTier One (for any operating systems).
- The host server signs up for admin via the ZeroTier website.
- The host creates a new network on the website. The network name can be anything you wish.
- On the network page, note there is "Network ID" and "Access Control" fields. ZeroTier users can join a network via the network ID. The access control field dictates if players can join your server with authentication or not. For the simplicty of this tutorial, lets set the access control to "Public"[note 1].
- The host installs and configures the Minecraft server software. The
server-ipfield inserver.propertiesis left blank (as default). - The host shares the network ID to each of the players.
- The players connect to the ZeroTier network via the network ID. This can be done through the ZeroTier One software, by right-clicking the tray menu, and click "Join New Network", inserting the network ID in the process.
- Now that all the machines are connected within the same ZeroTier network, the host gives their machine's ZeroTier IPv4 address to the players. On Windows, you can view your ZeroTier IPv4 address by running
ipconfig, and look for IPv4 address in "ZeroTier One" ethernet adapter. - Each player connects using this IP as per the usual Minecraft multiplayer screen.
- ↑ ZeroTier users can join a network via the network ID. If access control is set to "Public", then any one, including foreigners, can join your network, and potentially grief your server. To mitigate this, set the access control to "Private" and manually authorize each players, or use server whitelist.
Security recommendations
After setting up your server, it is recommended to follow these practices:
- Enable whitelist for your server. Exposing your Minecraft server to the public opens the door for other players or foreigners that you don't recognize, and can lead to griefing. Whitelist is configurable through whitelist.json or the
/whitelistcommand.- Whitelist only works with online mode. Offline mode servers make whitelist ineffective, as players can join with a different username included in the whitelist. You may use authentication mod instead for offline mode servers, though its effectiveness is questionable without a strong password.
- Griefers often scan vulnerable Minecraft servers by their public IP address on the Internet. They use automated scanner, and scan for characteristics that would indicate a Minecraft server is being hosted at specific IP, such as Minecraft's default port (25565), checking server online status from the server list, checking if it's joinable, etc. There are ways to mitigate these:
- Use different port for your Minecraft server. If you want players to join without specifying the port, use § SRV record for joining with a domain name instead.
- Enable online mode for your server. This will deter some griefers from joining your server with illegitimate account, and make whitelist more effective.
- Set the server's default game mode to Adventure mode. Adventure mode disables placing and breaking any blocks in your world, thus making griefing very ineffective. This way, you can select trusted players with Survival mode, which enable breaking and placing blocks. Do note though, Adventure mode players can still interact and kill mobs in your server.
- Only give out necessary permissions to run a Minecraft server. Such permissions like running as a super user are too extensive, and can leave out to security vulnerabilities.
- Close unused ports, and open ports when needed to prevent outside attacks and security exploits. This can be done by configuring firewall. Only open essential ports, such as Minecraft server's default port 25565, or your custom port. Remember to close the port when it is not needed anymore.
- If you're using Secure Shell (SSH), make sure to enable some form of authentication, such as password or SSH key.[5] SSH keys are akin to a secret password, and must be kept safe and private.
- Regularly update your server to the latest version, and avoid any releases known to have vulnerabilities.
- Regularly make server backups to safeguard your data against loss or corruption.
- Review your server plugins and mods for known vulnerabilities.
- Test plugins and mods on a separate server instance, and not your main one.
- For personal or private servers, use LAN connections as possible.
Connecting to the Minecraft server
Depending on which method you use to publish the server, here are couple of ways to connect into your Minecraft server:
- If you are playing on the same machine on which the server is running, select the "Multiplayer" option in the game client, click direct connect, and then type in
localhostinstead of an IP address. - Players within your LAN can connect to your server by using the server host's internal IP address; port forwarding is not required for such local connections. See § Getting the internal IP address for getting the internal IP address of the server host. If the port is set to a number other than 25565 in server.properties, that port must be included. This address (both IP and port) will look something like
192.168.0.168:25565. - Players connecting from the Internet (i.e., outside of your LAN) must connect using your external IP address. You must port forward for someone outside your network to connect to the server.
Domain name
Minecraft server can be connected through an Internet domain name, which is a custom string you can insert in the server address. You'll commonly see usage of domain name when visiting websites, for example, youtube.com, hypixel.net, minecraft.net, etc. These domain names are used in place of an IP address, where typing and remembering them is easier than numerical IP.
In order to use a custom domain name, you would need to register first through a domain registrar. Registering a domain name is often paid, and rarely ever free. You can register a custom domain name that ends with a prefix (e.g. "<your-domain-name>.net"), like ".com", ".org", ".net", and much more. Alternatively, you can get a free custom domain through a dynamic domain service, such as NoIP. These services would typically give you a custom sub-domain, which ends with another string before the prefix (e.g. "<your-domain-name>.example.com").
A record
After registering a domain, you can use it to point to your Minecraft server's IP address, so when player connect to your server, they can type your domain name instead of the server's IP address. This can be done by adding an A record (stands for address record) to your domain, which tells the game of the server's actual IP address from the domain name.
To do this, visit your domain's DNS records. This is usually provided through your domain registrar's website, in domain management or settings menu. If you haven't found it yet, please contact your registrar or visit their knowledge base for help.
In the DNS records, add a new A record with these values:
- Host: leave blank for when you want player to connect to your root domain (e.g. "example.com"), or insert your own custom sub-domain (e.g. "subdomain.example.com").
- Answer or value: your Minecraft server's external IP address (usually after port forwarding).
- TTL: stands for time to live, leave as is, or insert "600".
- Priority: a numerical value which "prioritize" the record. This can be useful if you have multiple A records, and a record with the highest priority number would overtake other records. Some registrar provide this field.
After adding the A record for your domain, wait for up to 10 minutes, as any DNS record updates are not instantaneous on other devices, including yours. When updated, players can connect to your server using your domain name, as specified in the "Host", or if blank, your root domain.
To learn more about A record, see this Cloudflare article.
SRV record
Since Java Edition 1.3.1, the game supports using custom ports without requiring the player to type it. This is achieved by using a SRV record (stands for service record) in the DNS. The SRV record tells Minecraft the actual server's IP and port to use from a domain name.
SRV record only points to a domain name with their specified port, so would you need to create an A record pointing to your Minecraft server first. Difference with A record is that you cannot specify the custom port, as A record only points to the IP address.
Minecraft server fetches SRV record information exclusively from _minecraft._tcp.<domain> domain name:
- Host:
_minecraft._tcp.<domain>, with <domain> is your designated domain name for your server. It can be added with sub-domain. For example, inserting_minecraft._tcp.play.example.orgwould make players connect to your server throughplay.example.org. - Answer or value: depending on your domain registrar, the answer or value may be formatted like
<weight> <port> <target>:- <weight> is similar to priority, a target with higher weight will receive more traffic, but priority is looked first.
- <port> must be your Minecraft server's port (default port is
25565). - <target> must be your domain that points to your Minecraft server's IP (can be a domain name with A record, or other records).
- An example of SRV record's answer value would be:
600 25565 mc.example.com.
- For other fields, see § A record default values.
To learn more about SRV record, see this Cloudflare article.
Verify DNS record
To manually verify whether your DNS record has been updated, you can run the following command: nslookup -q=<record-type> <domain> (for Windows only).
The <record-type> could be "a" or "srv" for A record and SRV record respectively.
For A record, if your server's IP address is not included in the "Addresses" field from the output, then it has not been updated yet.
For SRV record, your <domain> needs to be "_minecraft._tcp.<srv_domain>", where <srv_domain> is the domain name you have specified in the SRV record. An example output for your SRV record would be:
> nslookup -q=srv _minecraft._tcp.YOUR.DOMAIN.com
Server: UnKnown
Address: [REDACTED]
Non-authoritative answer:
_minecraft._tcp.YOUR.DOMAIN.com SRV service location:
priority = 5
weight = 5
port = 65312
svr hostname = ACTUAL.DOMAIN.com
Frequently asked questions (FAQ)
Q: I have a problem which is not answered in here! What should I do to?
A: Go to the Minecraft Forums and post your problem there. To help you, they need the following information:
- Operating system
- Version of Java
- One machine or multiple computers
- Exact description of the problem
- Steps you have taken to solve the problem
- Any errors you encountered
- Screenshots of the problem (if possible)
- Anything else that might help us to solve your problem—there almost never is too much information (but passwords and other personal data would be too much information!)
And please, if we were able to help you, post where the problem was exactly and what the fix was for that. Other people will appreciate that (and we will be able to get a grip on the common problems!)
Q: On a Windows computer, when I double click the batch file it opens a command prompt window, but quickly disappears and the server does not start.
A: This may be caused by an error from the Minecraft server. Batch scripts immediately exit when there is no more instruction to run, to fix this and see the error, right-click your .bat program and hit edit, add a new line, type pause, then save and run the file.
If it says invalid path, it is probably due to an incorrect path to Java executables or your Minecraft server jar file.
- For incorrect path to Java executables, you need to specify the correct Java executables path in your
PATHvariable. On Windows, Java executables typically lives underC:\Program Files\Java\jdk<version>\binorC:\Program Files (x86)\Java\jdk<version>\bin. Or if you've installed Adoptium's Temurin JDK/JRE previously, it may be underC:\Program Files\Eclipse Adoptium\<jdk>-<version>-hotspot\bin. Add these paths into yourPATHvariable accordingly.
- For other Java distributions and operating systems, please check their help page or search the Internet for help.
- For incorrect path to Minecraft server jar file, the server jar filename can be either
server.jarorminecraft_server.<version>.jar, or similar.
If it says other error, you should post a thread using the template and guidelines above.
Q: Whenever I try to get the server up, it says "Failed to bind to port!".
A: The most common reason this happens is because you put an IP address in the server-ip field in your server.properties file. If the IP you specify isn't the same as any of your network interfaces, (your wireless or wired IPv4 from ipconfig/ifconfig/ip a) Minecraft will throw the port binding failure message. By leaving it blank, you let it bind to all interfaces. You will then be able to connect using localhost and people on your wired/wireless network (in the same subnet) can connect using the computers/server's internal IP address.
Alternatively, the error can mean that you have tried to use a port or an IP address that is already in use or that you do not have permission to use. You can try a different port by changing it in your server.properties file in this line: server-port=25565.
You should avoid using the following ports for your server as some ISPs may block these ports for security reasons:
- 21 (Used by most FTP Servers)
- 22 (Used by Secure Shell daemon)
- 25 (Used by Mail Servers for SMTP)
- 53 (Used by DNS Servers)
- 80 (Used by most Web Servers)
- 110 (Used by most Mail Servers for POP3)
- 115 (Used by Simple File Transfer Protocol)
- 143 (Used by Mail Servers for IMAP)
- 443 (SSL port for Web Servers)
- 3306 (Used by most MySQL Servers)
Generally avoid any port numbers below 1024, since those ports are generally referred as well-known ports and are registered with the IANA for important services.
Q: I tried to run the server with Solaris/OpenSolaris and got the following error:
java.io.InterruptedIOException: Operation interrupted
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at java.net.SocketInputStream.read(SocketInputStream.java:182)
at java.io.FilterInputStream.read(FilterInputStream.java:66)
at gq.a(SourceFile:131)
at ji.g(SourceFile:197)
at ji.c(SourceFile:17)
at oq.run(SourceFile:84)
2011-05-31 16:57:26 [INFO] /:44673 lost connection
A: For whatever reason, out of all of the operating systems, only Solaris throws that exception when a thread interrupts a connection. A workaround is to change the default behavior on the command line:
java -Xmx1G -Xms32M -XX:-UseVMInterruptibleIO -XX:+UseConcMarkSweepGC \ -XX:+CMSIncrementalPacing -XX:ParallelGCThreads=$CPU_COUNT -XX:+AggressiveOpts\ -jar minecraft.jar --nogui
This instructs Java to use an interruptible IO stack instead of the default IO that is sensitive to interrupted threads.
Q: When I try to connect to my server this is what it says:
Connection lost The server responded with an invalid server key
A: This error is usually caused when the server sends an unrecognized function to the client, which may be caused by using outdated server, unrecognized or modded server, or it may be caused by the client with the same reasons (outdated, modded, etc.) In general, you should both check the server and the client softwares and their versions if they match.
Q: I cannot break/place any blocks!?
A: This is most usually caused by interacting with blocks in a protected area. If you are trying to interact near spawn, most likely it has been protected, by the Minecraft server software; either build away from it or get operator status.
Q: My server runs fine, but I cannot connect to it!
A: This could be caused by a series of issues. Please post a thread using the template and guidelines provided above.
Q: How do you give a .jar server more ram?
A: Change the numbers in the server launch command "-Xmx1G -Xms1G". The -Xms part specifies how much memory the server starts with, and the -Xmx specifies how much memory the server allowed to use.
For example:
-Xmx1G -Xms1G= maximum 1GB, starts with 1GB,-Xmx2G -Xms1G= maximum 2GB, starts with 1GB,-Xmx4G -Xms2G= maximum 4GB, starts with 2GB, and so on.
Please read § Java options to learn more about these options.
Q: Why is the server CPU constantly at full load?
A: This is most commonly caused by the server's performance problem.
- This can be caused by the server struggling to load too much entities, chunks, players, etc. This leads to the server needing to allocate more processing power to manage these elements.
- Use debug screen and commands to check for high entity counts. Remove non-important entities such as dropped items, monsters, and other entities you find not important. For example, you can use commands like
/kill @e[type=item]to remove all dropped items. - Note that players can load and persist chunks and entities in the game. You can limit this behavior by reducing the
view-distanceand thesimulation-distanceoptions in the server.properties.
- Use debug screen and commands to check for high entity counts. Remove non-important entities such as dropped items, monsters, and other entities you find not important. For example, you can use commands like
- If you server CPU still cannot handle the Minecraft server, then its probably the time to look for a new capable hardware to run your Minecraft server on. Minecraft can be resource-intensive, especially when hosting large worlds or many players.
- Check the Server/Requirements page and see if your hardware is fit to run a Minecraft server. Note that laptops, notebooks, and other low-end machines are not really a good machine to run a Minecraft server.
Q: Help! How do you find out your server's IP address?
A: There are two types of IP address: your internal IP address and your external IP address.
- For finding your internal IP address, which is mainly used for port forwarding and other local network related stuff, please read § Getting the internal IP address.
- For finding your external IP address, which is mainly used to let players join your port-forwarded server, please read § Port forwarding.
Q: I port forwarded and allowed java.exe in my firewall and it's still not working!
A: Your modem might be acting as a router as well. If you switch ISP's or upgrade your connection to the Internet, you may get issued a modem/router combination (which might explain why it worked in the past).
You can verify this by looking for the WAN IP of your router. If it's a internal IP, you'll need to log into the modem/router your ISP issued to you, and configure port forwarding to the external IP of your router. See § Port forwarding for detail instructions.
Q: I turned off my firewall on my router/modem how does it still not work? However, port forwarding sites report they can "see" me? What's going on?
A: Turning off your firewall on your router/modem means you essentially disabled port forwarding. Port forwarding is actually a subset of firewall rules. If no rule exists on that port (for example 25565), the firewall will ignore/drop the connection attempt (hence, you get a connection timed out). If there is a rule, it should pass on the connection to whatever computer is configured to receive the initial connection attempt.
When you disable the router/modem firewall and test your public IP address on a port forwarding-checking website, the website will request your router/modem, and your router/modem will respond to that request. This is another reason why disabling your firewall is bad; you incorrectly believe that people outside your network can connect to your Minecraft Server on your computer, when really, they're trying to connect to the router/modem itself.
To solve this, the next step is to confirm if your port forwarding (rules) are correct. By searching "minecraft server checker" on the Internet you'll be able to check if you configured your network correctly such that users outside your network running the Minecraft client can indeed connect to your computer through your router/modem.
Q: What is connection timed out and connection refused?
A: Simply put, connection timed out is when a firewall ignores a connection attempt (ignores the intial connection packet with the SYN flag in the 3-way handshake). Connection refused is when there's no process listening on the port; therefore, the operating system lets the client (in the standard client-server model) know their connection attempt did not work.
The default configuration on all Windows computers (the home version) and (just about) all (SOHO) routers is to drop or time out the connections. This is called "stealth mode" and you can read more about it on superuser. Here's a brief summary: "The idea is that refusing a connection instead of timing it out will tell an attacker that there actually is a computer on that IP-Address. With the connection attempt timing out, the hope is that the attacker will ignore the computer."
You can read more about connection refused on serverfault.
So if your error message is a connection timed out, it's usually a firewall problem; you either need to allow Java in the Windows firewall or port forward. If the error message is a connection refused, perhaps your Minecraft server has not started properly or you turned off the firewall on your router instead of port forwarding.
As always, you can always ask the Minecraft Forum if you are uneasy or unsure about something, particularly if opening the command prompt/terminal and running commands makes you nervous.
Connection filtered and connection closed is another way of saying timed out and refused, respectively.
Resources
Linux
- Linux tutorial for more advanced users
- How to Install Minecraft Server on CentOS
- How to make a Minecraft Server on Ubuntu for beginners
- Alternative port forwarding tutorial for Windows (with pictures)
Videos
Windows
macOS
Full course
References
- ↑ https://www.digitalocean.com/community/tutorials/how-to-install-java-on-freebsd-10-1
- ↑ https://www.freshports.org/faq.php#port
- ↑ "Minecraft Snapshot 24w04a" (§ Region file compression algorithm) by Java Team – Minecraft.net, January 24, 2024.
- ↑ https://stackoverflow.com/a/8296204
- ↑ https://tailscale.com/learn/ssh-security-best-practices-protecting-your-remote-access-infrastructure
External links
- How to Setup a Minecraft: Java Edition Server – Minecraft Help Center
- How to Download Dedicated Minecraft Server Software – Minecraft Help Center
