{{Missing information|the ''Bedrock Edition'' server software}}
{{exclusive|java}}
{{TOC|right}}
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, GNU/Linux and BSD.
For more information on ''Minecraft'' servers, see the [[Server]] page.
* Setting up a server takes some time, and some technical knowledge. Don't try to set up a server unless you have some basic computer and networking abilities. Better yet, take time to research any concepts you found unsure or uncertain before or while reading this tutorial.
* A ''Minecraft'' server does not need to be a high-end machine, but laptops and notebooks don't usually make for good server machines. They typically have lower-end hardware and bad I/O performance in comparison to desktop computers.
* 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. Typically, a survival server with 4-8 players can run on most modern hardware.
* If you decide you don't want to host, but still want to play online, check out the public server options on the official [https://aka.ms/verifiedservers server listing] by GamerSafer.
*To learn more about the system requirements to run a server, check out the [[Server/Requirements]] page.
*If you want to setup a quick and simple multiplayer server in your home, check out the [[Tutorials/Setting up a LAN world]]. Note that players must be connected to the same local network or Wi-Fi network.
*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 [https://www.spigotmc.org/ SpigotMC] and [https://papermc.io/ PaperMC], and if using mods, you can run [[Forge]] and [https://fabricmc.net/ Fabric] servers.
==Warning==
{{msgbox
| title = Note
| text = We encourage exploration and learning, but it's important to be aware that running server software without a solid understanding of its implications can expose your system to potential security risks. Make sure to take necessary precautions and seek guidance if you're unsure.
| type = delete
}}
Since you're about to run your own server, you should be aware of the possible dangers. Running by the instructions below should not put you at any risk, but this is a wiki which everybody is allowed to edit, and we don't know about your system configuration, so we can’t guarantee you'll be 100% out of danger.
In order to run your server and stay out of trouble, we highly suggest that you should at least know about the following:
*Using the command-line and editing configuration files
*Networking in general ([[wikipedia:IP|IP]], [[wikipedia:DHCP|DHCP]], [[wikipedia:Port (computer networking)|ports]], etc.)
*Your system configuration
*Your network configuration
*Your router configuration (if you want other people to connect over the Internet)
=== Security recommendations ===
Before setting up your server, it is recommended to follow these practices:
*Only give out necessary permissions to run a Minecraft server. Such permissions like running as a {{w|super user}} are too extensive, and can leave out to {{w|Vulnerability (computing)|security vulnerabilities}}.
*Close unused ports, and open ports when needed to prevent outside attacks and security exploits. This can be done by configuring {{w|Firewall (computing)|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 {{w|Secure Shell}} (SSH), make sure to enable some form of authentication, such as password or SSH key. If you're using password, its recommended that the password must be strong and secure. Create strong passwords with at least twelve characters long, and combine uppercase and lowercase letters, numbers, and special characters.https://tailscale.com/learn/ssh-security-best-practices-protecting-your-remote-access-infrastructure SSH keys are akin to a secret password, and must be kept safe and private. Never share SSH keys over insecure networks.
* 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 {{cmd|whitelist}} command.
*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 [[mod]]s for known vulnerabilities.
*Test plugins and mods on a separate server instance, and not your main one.
*For personal or private servers, use {{w|LAN}} connections as possible.
==Java==
[[File:Java.png|120px|right|frameless]]
[[Wikipedia:Java (programming language)|Java]] is a programming language designed to create programs for the [[Wikipedia:Java virtual machine|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.
This section is designed to answer some frequently asked questions about Java and guide you through some decisions regarding Java.
====OpenJDK vs Oracle JDK====
OpenJDK and Oracle JDK are very similar. OpenJDK is the official open source {{w|reference implementation}} of Java. OpenJDK is an open source codebase that almost all other JDKs are built on. Excluding packaging, cosmetic and license differences, [https://www.oracle.com/technetwork/java/javase/overview/oracle-jdk-faqs.html OpenJDK is the same as OracleJDK].
Oracle's ''Java SE Development Kit'' (JDK) builds were published under [https://www.oracle.com/downloads/licenses/javase-license1.html Oracle Technology Network (OTN) license], which require a paid subscription for [https://www.carehart.org/blog/client/index.cfm/2019/1/1/how_oracles_java_change_applies_to_any_production_use commercial and production] purposes. This likely includes running a ''Minecraft'' server even if it is non-profit. Oracle does provide its own OpenJDK builds, but they are not packed into an installer format for easy use.
There are several [[Tutorials/Update_Java#Where to download|OpenJDK distributions]] out there, with the most popular one being [https://adoptium.net/ Adoptium's OpenJDK ''Temurin''].
Alternatively, Microsoft also offers their own [https://learn.microsoft.com/en-us/java/openjdk/overview build of OpenJDK]. It is the Java build bundled with the ''Minecraft Launcher'', and is available for commercial purposes.
====JRE vs JDK====
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.
====Java version====
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 {{section link|Tutorials/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.
While servers can run on older versions of Java, it is recommended to run on the latest version supported by the game, as newer releases offer bug fixes, security and performance improvements.
====Headless Java====
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.
{{Quote|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.|[https://wiki.debian.org/Java/ Debian Wiki]}}
==Java installation==
The ''Minecraft'' server requires the {{w|Java Runtime Environment}} (JRE). Downloading and installing the {{w|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 [https://www.java.com/en/download/uninstalltool.jsp Java Uninstall Tool]. The software will check for your installed Java version, and removes older Java installation if necessary.
*Open {{w|Windows Command Prompt}}, and run the command java -version
. If a version number is reported, see {{slink|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 [https://adoptium.net/ Adoptium's OpenJDK Temurin] or [https://learn.microsoft.com/en-us/java/openjdk/download Microsoft build of OpenJDK].
====Winget====
{{w|Windows Package Manager|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:
* {{cd|winget install EclipseAdoptium.Temurin.21.JRE}} for Adoptium Temurin 21 JRE-only.
* {{cd|winget install EclipseAdoptium.Temurin.8.JRE}} for Adoptium Temurin 8 JRE-only.
* {{cd|winget install Microsoft.OpenJDK.21}} for Microsoft build of OpenJDK 21. Microsoft build of OpenJDK 8 is not available.
===macOS===
Keep in mind that the server won't run correctly on macOS 10.4 and earlier and may crash your machine.
*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 {{cd|brew tap homebrew/cask-versions}} for the next steps to install specific version of OpenJDK.
**Run {{cd|brew install --cask temurin@21}} to install Adoptium Temurin 21.
**Run {{cd|brew install --cask temurin@8}} to install Adoptium Temurin 8.
*Run java -version
again to see your Java version.
===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 {{cd|apt}}:
* Before installing, it is recommended to run {{cd|sudo apt update}}.
* {{cd|sudo apt install openjdk-21-jdk-headless}} for OpenJDK 21.
* {{cd|sudo apt install openjdk-8-jdk-headless}} for OpenJDK 8.
Removing the {{cd|-headless}} part of the command will install GUI components of Java.
====Fedora, Alma Linux, Rocky Linux, CentOS, RHEL-based====
OpenJDK can be installed using {{cd|dnf}}:
* {{cd|sudo dnf install java-21-openjdk-headless}} for OpenJDK 21.
* {{cd|sudo dnf install java-1.8.0-openjdk-headless}} for OpenJDK 8.
Removing the {{cd|-headless}} part of the command will install GUI components of Java.
====openSUSE====
OpenJDK can be installed by using {{cd|zypper}}:
* {{cd|sudo zypper install java-21-openjdk}} for OpenJDK 21.
* {{cd|sudo zypper install java-1_8_0-openjdk}} for OpenJDK 8.
It is recommended to use openSUSE Leap rather than {{w|rolling-release}} Tumbleweed for server stability.
====Arch Linux====
OpenJDK distributions are available on Arch Linux repository.
OpenJDK can be installed by using {{cd|pacman}}:
*{{cd|pacman -S jre21-openjdk-headless}} for OpenJDK 21.
*{{cd|pacman -S jre8-openjdk-headless}} for OpenJDK 8.
Removing the {{cd|-headless}} part of the command will install GUI components of Java.
If you encounter issues, it is recommended that you refer to the official [https://wiki.archlinux.org/index.php/java Arch Linux Wiki]. (see also [https://wiki.archlinux.org/title/Minecraft/Java_Edition_server 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 [https://wiki.gentoo.org/wiki/Java#Installing_a_virtual_machine Gentoo Wiki].
====Solus====
Run sudo eopkg install openjdk-21
to install OpenJDK 21.
For older versions of Java refer to [https://help.getsol.us/docs/user/software/development/java/ Solus Help Center].
====Other distributions====
Check your distro's documentation. It should have information on how to install OpenJDK.
Alternatively, you can [https://www.java.com/en/download/linux_manual.jsp 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 {{cd|pkg}}:https://www.digitalocean.com/community/tutorials/how-to-install-java-on-freebsd-10-1
* {{cd|pkg install openjdk21}} for OpenJDK 21.
* {{cd|pkg install openjdk8-jre}} for OpenJDK 8 JRE-only.
Once you have installed OpenJDK, you may see OpenJDK requires {{cd|fdescfs}} and {{cd|procfs}}. In order to satistfy this requirements, you can run the following commands:
* {{cd|mount -t fdescfs fdesc /dev/fd}} for {{cd|fdescfs}} mounted on {{cd|/dev/fd}}.
* {{cd|mount -t procfs proc /proc}} for {{cd|procfs}} mounted on {{cd|/proc}}.
This changes are not permanent on the next system reboot. In order to make them permanent, you need to add these mountpoints on your {{cd|/etc/fstab}} file. Open them with your text editor (such as nano or vi) and insert the following lines into {{cd|/etc/fstab}}:
fdesc /dev/fd fdescfs rw 0 0 proc /proc procfs rw 0 0Lastly, you will want to rehash to be sure that you can use your new Java binaries immediately, run {{cd|rehash}} in the command line. For installing OpenJDK using ports instead, please visit this [https://www.digitalocean.com/community/tutorials/how-to-install-java-on-freebsd-10-1 website] for more information. Packages from {{cd|pkg}} are compiled binaries of the ports.https://www.freshports.org/faq.php#port ==Docker== {{disclaimer|section=1}} {{w|Docker (software)|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 [https://docs.docker.com/install/ documentation website]. Here is a step-by-step to setup a ''Minecraft'' server using Docker: #Download the image by running
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 {{cd|java -jar server.jar}}. If you don't want a GUI for typing commands, add a space and {{cd|--nogui}} to the command. You can also use a few other switches described below.
At this point you should have a basic server running. See {{section link||Configuring the environment}} for more information about configuring your server. One of the things you definitely want to do is [[#Writing a script to launch the server|writing a script to launch the server]] so you don't have to remember the command line.
===Java options ===
Java options should be added between the {{cd|java}} and the {{cd|-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. {{cd|-Xmx}} defines how much memory it is allowed to use. {{cd|-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.
:{{cd|-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, {{cd|-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" ({{cd|1=-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 {{cd|-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'': {{cd|1=-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 [https://github.com/brucethemoose/Minecraft-Performance-Flags-Benchmarks#server-g1gc brucethemoose's Minecraft Performance Flags] and [https://aikar.co/2018/07/02/tuning-the-jvm-g1gc-garbage-collector-flags-for-minecraft/ 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 {{cd|-XX:+UnlockExperimentalVMOptions -XX:+UseZGC}}. Tuning flags other than {{cd|-Xmx}} are [https://docs.oracle.com/en/java/javase/17/gctuning/z-garbage-collector.html#GUID-9957D441-A99A-4CF5-9522-393E6DE7D898 a lot less important] compared to in GCs (because the default is quite good), although {{cd|1=-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 [https://github.com/brucethemoose/Minecraft-Performance-Flags-Benchmarks#graalvm-enterprise-edition instructions from brucethemoose].
To sum up, a reasonable flag combination can be as simple as {{cd|1=-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 [[Mods|modified server software]]. In fact, all serious discussions (e.g. Aikar and brucethemoose) of server performance assume some degree of modding.
===Minecraft options===
Options for the server JAR go ''after'' the {{cd|-jar server.jar}} part. Run with {{cd|--help}} to see all available arguments that can be passed to the server. Below is a list of available commandline options for the server.
;{{cd|--bonusChest}}
:If a [[bonus chest]] should be generated, when the world is first generated.
;{{cd|--demo}}
:If the server is in demo mode. (Shows the players a demo pop-up, and players cannot break or place blocks or eat if the demo time has expired)
:Equivalent to playing ''Minecraft'' without a account, you have about 5 in-game days before your trial ends.
;{{cd|--eraseCache}}
:Erases the lighting caches, etc. Same option as when optimizing single player worlds.
;{{cd|--forceUpgrade}}
:Forces upgrade on all the chunks, such that the data version of all chunks matches the current server version (same as with sp worlds).
:This option significantly increases the time needed to start the server.
;{{cd|--help}}
:Shows this help.
;{{cd|--initSettings}}
:Loads the settings from 'server.properties' and 'eula.txt', then quits.
;{{cd|--jfrprofile}}
:Initializes the Java Flight Recorder on the server. Only available on 1.18+.
; {{cd|--nogui}}
:Doesn't open the GUI when launching the server.
:You will still be able to interact with your server, but you must use the cmd or Terminal if enabled.
:*{{cd|nogui}} does the same thing as this option for backward compatibility with very old versions of the server, but {{cd|--nogui}} is preferable as it matches the format of other options.
;{{cd|--safeMode}}
:Loads level with vanilla datapack only.
;--serverId
:Gives an ID to the server.
:Used only in crash reports. If not given, then the "Server Id" detail is not added to crash reports.
;--universe
: The folder in which to look for world folders. (default: {{cd|.}}, the current directory)
The following options are available from [[server.properties]] too. It might be a better idea to edit that file instead for easier management:
;--world
:The name of the world folder in which the level.dat resides. (default: {{cd|world}})
:This is the same as {{cd|level-name}}.
;--port
:Which port to listen on, overrides the server.properties value. (default: -1, read from server.properties)
: See [[server.properties]], option "server-port", for restrictions on this value.
===Example command line===
*Running a world found in the folder "cold" on port 1337, with 1G of RAM allowed: {{cd|java -Xmx1G -jar server.jar --port 1337 --nogui --world cold}}.
==Configuring the environment==
===Writing a script to launch the server===
It's definitely boring and tedious to write the command-line options for your server every time you launch it. Luckily, we can write it down in a file and just run that instead.
====Windows====
Windows uses {{w|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:
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 [[command]]s. In other words, [[operator]] privileges allow you to control certain aspects of the game (e.g., teleporting players).
#*Example of {{cd|ops.json}} contents:whitelist.json
by typing {{cmd|whitelist add <''player''>}} into the server console or gui. Due to the transition to the UUID system, it is not recommended to directly edit whitelist.json
.
==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===
{{about|LAN connections in a dedicated server|singleplayer world LAN|Tutorials/Setting up a LAN world|section=yes}}
{{see also|Wikipedia:Local Area Network}}
'''Local Area Network''' (LAN, or local network) is a {{w|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 {{w|Router (computing)|router}}, your device 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 {{w|private network}}.
Each device in the network is given an unique identifier called {{w|IP address}}. When used in a LAN setting, these IP addresses are often referred to as internal IP address, as they belong to {{w|Private network|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 {{cd|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 {{cd|192.168.1.2}} and the port number is {{cd|25565}}, you would connect to the server using the address {{cd|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 {{w|ethernet cable}} or {{w|Wireless router|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:
*;{{OS|Win}} Windows
*:Press {{key|Win+R}}; this should be up to the "Run" dialog box. Type {{cd|cmd}} and hit {{key|Enter}}. This should open a command window with a black background. From there, type {{cd|ipconfig}} and press {{key|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''.
*;{{OS|Mac}} macOS
*:[[File:Ip-address-mac-610x206.jpg|thumb|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.
*;{{OS|Linux}} Linux
*:Open the terminal, and run {{cd|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 {{cd|ethX}} or {{cd|enpXsX}}, and for wireless, {{cd|wlanX}} or {{cd|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 {{cd|inet}}, which will look like {{cd|inet xxx.xxx.xxx.xxx}}, copy the {{cd|xxx.xxx.xxx.xxx}} numbers down.
===Port forwarding===
{{see also|Wikipedia: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 {{w|Internet}}.
When port forwarding on your router{{fn|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.}}, 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 [https://www.ipchicken.com/ IP Chicken].
Port fowarding settings may vary across different routers. If your router settings is different from this article, or if you don't understand how to configure it, please visit [https://portforward.com/ 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.''
With that in mind, here is the process on how to port forward your ''Minecraft'' server that should be applicable to most routers.{{fn|Most port forwarding guides do not perfectly match the router's settings, including this one, but the process should be similar with may be small differences.}}
#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 {{cd|ipconfig}}, and find the IP address next to {{cd|Default Gateway}} column.
# 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 [[#Getting the internal IP address|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.
{{fnlist}}
====Port forwarding notes====
*The [http://portforward.com/english/applications/port_forwarding/Minecraft_Server/Minecraft_Serverindex.htm 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 [http://www.yougetsignal.com/tools/open-ports/ 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 [http://www.yougetsignal.com/what-is-my-ip-address/ YouGetSignal].
====Dynamic IP issues====
{{see also|Wikipedia:Dynamic IP}}
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 {{w|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 [http://wanip.info/ 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===
{{see also|Wikipedia:Virtual Private Network}}
{{disclaimer|section=1}}
'''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.
Before we continue, it is recommended to follow these guidelines:
* '''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.
* Do not use VPN software without knowing how it works, as misconfiguration can lead to problems and networking issues on your operating system.
* Do not give or "run as" privileged or administration access to software that you don't trust, or without knowledge.
There are three common VPN software you can use for connecting your Minecraft server: {{w|LogMeIn Hamachi}}, [https://www.radmin-vpn.com/ Radmin VPN], and {{w|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 [https://www.vpn.net/ Windows, Mac], or [https://www.vpn.net/linux Linux]{{note|32-bit and 64-bit {{cd|.deb}} and {{cd|.rpm}} packages are available. For Gentoo, you can install it by emerging "net-misc/logmein-hamachi".}}.
#The host server signs up for admin via the [https://www.vpn.net/ LogMeIn website].
# On the host machine, a new Hamachi network is created.
#The host installs and configures the ''Minecraft'' server software. The {{cd|server-ip}} field in {{cd|[[server.properties]]}} is 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.
{{notelist}}
====Radmin VPN====
#Download and install [http://www.radmin-vpn.com/ 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 -> you are welcome to run ''Minecraft''.
#Connection: after program launch press “Join network" —> in the dialog box press enter Network name and Password received from the network administrator —> "Join" —> 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 [https://www.zerotier.com/download/ ZeroTier One] (for any operating systems).
# The host server signs up for admin via the [https://www.zerotier.com/ 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|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]].}}.
# The host installs and configures the ''Minecraft'' server software. The {{cd|server-ip}} field in {{cd|[[server.properties]]}} is 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 {{cd|ipconfig}}, and look for IPv4 address in "ZeroTier One" ethernet adapter.
# Each player connects using this IP as per the usual ''Minecraft'' multiplayer screen.
{{notelist}}
==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 {{cd|localhost}} instead of an IP address.
**''Both hosting and playing on the same machine is not a recommended practice unless you have a powerful computer (e.g. more than 6 gigabytes of ram). See [[Server/Requirements]] for more information.''
*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 {{section link||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 {{cd|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 forwarding|port forward]] for someone outside your network to connect to the server.
==Miscellaneous==
===Classic servers in local network===
{{msgbox
| title = This only applies to Classic (v0.30) servers.
| type = edition
}}
A common problem for server administrators is the inability to connect to your own server via another machine on your local network. A typical scenario for this is that you have a Classic server running on a dedicated machine, and you have your own machine which you play on. They're both connected to the same router/switch, and have internal IP's with the octets '192.168.x.x'. Normally, connecting via the URL generated for your server will result in an error message claiming that the server is offline.
To correct this, you must add a function to the end of your URL, bookmarks, or whatever else you connect by. The function is: '''?override=true'''> 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 [http://www.minecraftforum.net/forum/152-server-support/ 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 {{cd|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 {{cd|PATH}} variable. On Windows, Java executables typically lives under {{cd|C:\Program Files\Java\jdk
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 [[wikipedia:List of TCP and UDP port numbers#Well-known ports|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 connectionA: 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 --noguiThis 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 keyA: 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|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: * {{cd|-Xmx1G -Xms1G}} = maximum 1GB, starts with 1GB, * {{cd|-Xmx2G -Xms1G}} = maximum 2GB, starts with 1GB, * {{cd|-Xmx4G -Xms2G}} = maximum 4GB, starts with 2GB, and so on. Please read {{section link||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 {{cd|view-distance}} and the {{cd|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 {{section link||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 {{section link||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 {{section link||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. [https://superuser.com/questions/356043/windows-7-firewall-causing-remote-connection-to-time-out-should-refuse-connecti 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."
[https://serverfault.com/questions/725262/what-causes-the-connection-refused-message 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===
*[http://www.minecraftforum.net/viewtopic.php?t=628 Linux tutorial for more advanced users]
*[https://trickscage.net/install-minecraft-server-centos/ How to Install Minecraft Server on CentOS]
*[https://thishosting.rocks/how-to-make-a-minecraft-server/ How to make a Minecraft Server on Ubuntu for beginners]
*[http://www.minecraftforum.net/viewtopic.php?t=836 Alternative port forwarding tutorial for Windows (with pictures)]
==Videos==
===Windows===
{{yt|7mcFx_F8m5I}}
{{yt|8p9asAZQHTY}}
===macOS===
{{yt|1WKDbuFr9lc}}
===Full course===
*[https://www.youtube.com/playlist?list=PL5aiq8Z-dwu2OlNWkSZ5RYBfHUwTKGGHA YouTube playlist for How to Make a Server]
==References==
{{reflist}}
== External links ==
* [https://help.minecraft.net/hc/en-us/articles/360058525452-How-to-Setup-a-Minecraft-Java-Edition-Server How to Setup a ''Minecraft: Java Edition'' Server] – [[Minecraft Help Center]]
* [https://help.minecraft.net/hc/en-us/articles/4408873961869-How-to-Download-Dedicated-Minecraft-Server-Software How to Download Dedicated Minecraft Server Software] – [[Minecraft Help Center]]
== Navigation ==
{{Navbox tutorials|servers}}
[[Category:Server]]
[[de:Anleitungen/Server erstellen]]
[[es:Tutoriales/Configuración de un servidor]]
[[fr:Tutoriels/Configurer un serveur]]
[[ja:チュートリアル/サーバーのセットアップ]]
[[ko:튜토리얼/서버 설치]]
[[lzh:教章/立伺服器]]
[[pt:Comunidade:Tutoriais/Como configurar um servidor de Minecraft]]
[[ru:Создание и настройка сервера]]
[[uk:Керівництва/Створення та налаштування сервера]]
[[zh:Tutorial:架设Java版服务器]]