Tutorial: Setting up a Java Edition server

This feature is exclusive to Java Edition.
 

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

tl;dr: For most users, a Minecraft server runs on Java, so you should be careful to pick which one. It is recommended to pick the latest LTS Java version which Minecraft uses, that is Java 21. Use Adoptium's OpenJDK Temurin for free distribution of 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.

There are several virtual packages used in Debian for Java. These cover runtime compatibility and come in two flavors; headless (omits graphical interfaces) and normal.

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:

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.JRE for Adoptium Temurin 21 JRE-only.
  • winget install Microsoft.OpenJDK.21 for 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 java -version again 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-headless for OpenJDK 21.
  • sudo apt install openjdk-8-jdk-headless for 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-headless for OpenJDK 21.
  • sudo dnf install java-1.8.0-openjdk-headless for 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-openjdk for OpenJDK 21.
  • sudo zypper install java-1_8_0-openjdk for 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-headless for OpenJDK 21.
  • pacman -S jre8-openjdk-headless for 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 openjdk21 for OpenJDK 21.
  • pkg install openjdk8-jre for 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/fd for fdescfs mounted on /dev/fd.
  • mount -t procfs proc /proc for procfs mounted 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

The contents of this section are not supported by Mojang Studios or the Minecraft Wiki.
This section is optional and may be skipped. Installation of Minecraft server in Docker is for advanced users, and not necessary if you are running a server on your home computer.

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:

  1. Create a directory for the container.
  2. 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
    
  3. Start the container (and the Minecraft server) by running docker compose up -d in that directory.
  4. 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, then docker compose up -d to 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.txt will be generated after you run the server for the first time. Open it in a text editor and change eula=false to eula=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 --nogui to 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

The contents of this section are not supported by Mojang Studios or the Minecraft Wiki.
Don't trust third-party script from the Internet. Always check the script for any malware or suspicious activity before running. This section is also optional and may be skipped, as the startup script before is enough to start a Minecraft server, with additional options on the next sections.

Alternatively, you can manage and automate the startup and shutdown of the Minecraft server using scripts and tools listed below:

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

Be careful giving any player an operator status, as they give privileges and permissions to execute any commands, including stopping your server, giving players Creative mode, and enabling extensive modifications of the world that can be used for griefing.

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.json contents

ops.json

[
  {
    "uuid": "069a79f4-44e9-4726-a5be-fca90e38aaf5",
    "name": "Notch",
    "level": 4,
    "bypassesPlayerLimit": false
  }
]

Whitelist

Using whitelist is recommended for your Minecraft server, as whitelist blocks any unwanted players that may access and possibly grief your server without notice.

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.json contents

whitelist.json

[
  {
    "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:

An interactive widget is being loaded. If this does not work for you, please reload the page or check if JavaScript is working or enabled.

Java options

Generally, users should not worry about these options for their server, as the default values are fine for running a server. Modern JVM (i.e. 17, 21 or higher) are quite good at handling various applications with default settings. For generating server options automatically, you may visit Start Script Generator by PaperMC.

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. -Xmx defines 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 -Xmx if 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=32M works 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 -Xmx are a lot less important compared to in GCs (because the default is quite good), although -XX:-ZProactive is 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:

tl;dr: For most users, it is enough to do § Port forwarding to make your server playable with other players on the Internet (or long distance). § Virtual Private Network may be used if you cannot do port forwarding for whatever reason.

Local Area Network

This section is about LAN connections in a dedicated server. For singleplayer world LAN, see Tutorials/Setting up a LAN world.

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 Windows
    Press ⊞ Win + R; this should be up to the "Run" dialog box. Type cmd and hit ↵ Enter. This should open a command window with a black background. From there, type ipconfig and 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.
  • macOS macOS
    The IP location on OS X
    Locate your way to your desktop. Pull up the apple menu under the logo and scroll down to System Preferences; then select "Network" your IP should be on the lower right as "IP address (xxx.xxx.xxx.xxx)". Once you have your IP, copy it down.
  • Linux 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 with ethX or enpXsX, and for wireless, wlanX or wlpXsX. 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 to inet, which will look like inet xxx.xxx.xxx.xxx, copy the xxx.xxx.xxx.xxx numbers 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.

In order to find your external IP, you can google "what is my IP", or find at websites such as IP Chicken. External IP can sometimes be referred to as "public IP".
Port forwarding settings may vary across different routers. If you don't understand how to configure it, please visit portforward.com for more information. It is not recommended to configure your router settings without knowing how it works, as it may lead to security risks and networking issues.
Most port forwarding guides do not perfectly match the router's settings, including this one, but the general idea should be similar with small differences.

With that in mind, here is the process on how to port forward your Minecraft server that should be applicable to most routers:

  1. 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.
  2. 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 to Default Gateway column.
  3. Find your router's port fowarding settings.
  4. 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.
  5. For internal IP input, insert the server host's internal IP address.
  6. For external IP input, leave it as is.
  7. 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.
  1. 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

The contents of this section are not supported by Mojang Studios or the Minecraft Wiki.

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.

Always download and install software from trusted sources, usually from the official website. Malicious and fake software can steal your personal information, your passwords and credentials, and corrupt your operating system.

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

  1. Install Hamachi on each computer that wishes to participate in the server, including the host. Download Hamachi for Windows, Mac, or Linux[note 1].
  2. The host server signs up for admin via the LogMeIn website.
  3. On the host machine, a new Hamachi network is created.
  4. The host installs and configures the Minecraft server software. The server-ip field in server.properties is left blank (as default).
  5. The host passes the newly created Hamachi network credentials to each of the players.
  6. The players connect to the host's Hamachi network.
  7. Now that all the machines are connected within the same Hamachi network, the host gives their machine's Hamachi IPv4 address to the players.
  8. Each player connects using this IP as per the usual Minecraft multiplayer screen.
  1. 32-bit and 64-bit .deb and .rpm packages are available. For Gentoo, you can install it by emerging "net-misc/logmein-hamachi".

Radmin VPN

  1. Download and install Radmin VPN
  2. 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.
  3. Now the new network will appear in the main window → invite friends, send them the info to connect → then run the Minecraft game.
  4. 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

  1. Install ZeroTier One on each computer that wishes to participate in the server, including the host. Download ZeroTier One (for any operating systems).
  2. The host server signs up for admin via the ZeroTier website.
  3. The host creates a new network on the website. The network name can be anything you wish.
  4. 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].
  5. The host installs and configures the Minecraft server software. The server-ip field in server.properties is left blank (as default).
  6. The host shares the network ID to each of the players.
  7. 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.
  8. 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.
  9. Each player connects using this IP as per the usual Minecraft multiplayer screen.
  1. 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 /whitelist command.
    • 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 localhost instead 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.org would make players connect to your server through play.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 PATH variable. On Windows, Java executables typically lives under C:\Program Files\Java\jdk<version>\bin or C:\Program Files (x86)\Java\jdk<version>\bin. Or if you've installed Adoptium's Temurin JDK/JRE previously, it may be under C:\Program Files\Eclipse Adoptium\<jdk>-<version>-hotspot\bin. Add these paths into your PATH variable 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.jar or minecraft_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-distance and the simulation-distance options in the server.properties.
  • 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

Videos

Windows

macOS

Full course

References

External links

Navigation