User:ExtremeHeat11/sandbox/Setting up a server

From Minecraft Wiki
Jump to: navigation, search
Warning

Before following these instructions please note that running server software on your computer without a clear understanding of what you are doing may seriously harm your system and lead to vulnerabilities.[1]

This tutorial takes you through the steps of setting up your own server using the default server software that Mojang distributes free of charge. The software may be installed on most operating systems, including Windows, Mac and Linux.

Regardless of your operating system, you must begin by downloading the server software from the minecraft download page, and save it to the directory in-which you will run the server.


Note: There is also custom server software available, which most large servers use, but these applications are not supported by Mojang.

Warning[edit]

Since you're about to run your own server, you should be aware of the possible dangers. Although we can not prevent people from running their server and putting themselves at risk, we may at least appeal that you don't do it when having no idea what you actually do. Running by the instructions below should not put you at any risk, but since this is a wiki which everybody is allowed to edit, and we don't know about your system configuration, we cannot guarantee you'll be out of danger. In order to run your server and stay out of trouble, we strongly recommend you should at least know about the following:

  • Networking in general (IP, DHCP, ports etc.)
  • Your system configuration
  • Your network configuration
  • Your router configuration (if you want other people to connect over Internet)

Alternatively, if you decide that you don't wish to create a server, you are welcome to join other servers, which can be found here.

Getting started[edit]

To get started, you want to first install the latest server jar or exe depending on your operating system from https://minecraft.net/download. You must use the .jar version if you are on Mac OS X or Linux. If you are on Windows, you have a choice to use either the jar or the exe files.

For the purposes of this tutorial, we will refer to the files as minecraft_server.1.13.2.exe or minecraft_server.1.13.2.jar, but you can replace this with the filename you are using. For example, if your server file is named minecraft_server.1.6.4.jar and an instruction says to use a command such as java -jar minecraft_server.1.13.2.jar you would instead use java -jar minecraft_server.1.6.4.jar.

You can then start setting up your server.

Jump to: Windows instructionsMac OSX instructionsLinux instructions.

Windows instructions[edit]

Verify that Java is installed[edit]

You must first verify that the Java runtime environment (JRE) is installed on your computer.

To do so, follow the following steps:

  1. Hold your Windows key, then press 'R'; and in the prompt, type "cmd" and press OK.
  2. In Command Prompt, execute the command: java -version
  3. If the first line that it returned did not say java version "???", then you do not have a valid install of Java on your system; and should install the appropriate version from here.


Start the Minecraft server[edit]

If you have not already done so, create a dedicated folder somewhere on your PC for which you will run the server in. You should not use generic places like the Desktop or your Downloads folder.

Move the server software that you downloaded over to the new folder that you made and run it by double clicking it. The first time you run the server it will close immediately after and generate a few files, one of which should be called "eula.txt".

You must open this file, and set the second line of the file which should read eula=false to eula=true. By doing so, you are in agreement to the Minecraft End User Licence Agreement.

You can then start the server again and it should continue starting the server as normal. If you are hosting the server locally on your PC, you may connect to the server directly by using localhost to connect in-game.

To allow other people to connect to your server, you must use a method such as #Port forwarding if you are using a router provided by either you or your Internet Service Provider.

Or if you are using a router and just want to let people on your local area network (LAN) connect, you can open a Command prompt by searching for it at Start and run the command ipconfig /all | find "IPv4". This will give you a list of local IPv4 addresses that others on your network can connect to.

When either port forwarding or letting people on your LAN connect, you must ensure that you do not have any firewalls, either Windows Firewall or any 3rd party software blocking the external connections.

Starting via command line[edit]

More advanced users can start the server command-line for more control over the server. This allows you to add JVM flags to the server that can help to increase the allocated memory that the server can use, for example.

It is worth noting that increasing the memory on your server will not directly increase your performance, rather it will simply add more capacity to the server for running tasks and storing information to memory.

To have your server automatically launch with specified command line arguments, open the folder which contains the server and ⇧ Shift + Right click to get an extended context menu and press "Open command window here".

Create a text file by using one of the following commands depending on if you are using the Java archive or executable.

.exe version: echo java -jar minecraft_server.1.13.2.exe > run.bat && echo pause >> run.bat

.jar version: echo java -jar minecraft_server.1.13.2.jar > run.bat && echo pause >> run.bat

A file named "run.bat" should be generated, which you can run to start the server. You should be able to right click the file and select "Edit" to add additional arguments when starting the server.

Adding more RAM[edit]

If you haven't read the above, please see it.

Right click "run.bat", and select Edit. Refer to the first line and before the -jar argument, prepend the -Xmx argument to allocate more RAM capacity to the server. Note that this argument will only be setting the maximum amount of memory that the JVM will be able to use. This means that when you start the server, Java will allocate more memory when the server needs it up until it hits the limit you set.

Here's a conversion table you can use for adding more RAM with the -Xmx argument; please keep in mind that if you are on a 32-bit OS or Java installation, you will be unable to allocate more than 1500MB RAM.

RAM JVM Argument
1 GB -Xmx1G
1.5 GB (1500MB) -Xmx1500M
2 GB -Xmx2G
2.5 GB (2500MB) -Xmx1500M
3 GB (2500MB) -Xmx2G
3.5 GB (2500MB) -Xmx3500M

Once you have the JVM Argument, add it to the line as explained, so replace java -jar with java [JVM Argument] -jar.

For example, you could use java -XMX3G minecraft_server.(exe|jar) to launch the server with 3 Gigabytes of RAM.

Mac OS X instructions[edit]

Setting a server up in Mac OS X, requires a bit more work..

Getting started[edit]

Ensure you have the latest server application software. Look above for instructions.

Mac OS X already comes with its own version of Java that is updated automatically via Software Update (Apple menu > Software Update), so you don't have to worry about that.

  • Create a folder, which you want to run the server from.
  • Drag the server jar to the folder you created.
  • Open TextEdit, set the format to plain text (Format > Make Plain Text), copy and paste in the following:
#!/bin/bash
cd "$(dirname "$0")"
exec java -jar minecraft_server.jar
  • Name the file start.command or anything you wish, so long as it contains a .command file type.
  • Then, save this file to the new folder you made for the server.
  • Open Terminal, by either searching it at Spotlight, or manually going to Application -> Utilities -> Terminal.
  • In Terminal, type in chmod a+x , then drag the new file you just saved with TextEdit into the terminal, which should later look like chmod a+x /Users/User/path/to/file.
  • Press the return key, and then you can close terminal.
  • Afterwards, simply run the .command file that you created, and the server should run.

Using Time Capsule[edit]

Some homes use AirPort Time Capsule as a wireless router instead of other brands. This section will teach you how to set one up without messing up your file server.

NOTE: Make sure you have your admin username and password.

  • Open System Preferences > Network.
  • Click the Advanced button and go under TCP/IP.
  • Where it says Configure IPv4, change that option to Using DHCP with manual address.
  • Change the IP address to 10.0.1.x, where x can be any number from 1 to 100.
  • Now go to the Sharing section and make sure that Internet Sharing is on.
  • Now, open up AirPort Utility and edit your Time Capsule settings.
  • Go under Network and make sure the option Router Mode is set to DHCP and NAT. Now, click the + button under the Port Settings.
  • Type in the following:
    • Description: Minecraft Server (or whatever you want to call it)
    • Private IP Address: The address you chose for the 4th step.
  • Change everything with the word port in it to 25565.
  • Now hit Save and update the Time Capsule.

That's it! You're now ready to configure your server.

Run as a daemon[edit]

Alternatively you can automate the startup of the Minecraft server.

Create a Mac OS X startup daemon

Linux instructions[edit]

This tutorial for how to set up a Minecraft server on Linux was designed for people who don't have a lot of experience with Linux. There is a more advanced tutorial in the forums. This tutorial was tested on Ubuntu 9.10 32-bit but should work with the descendants of Debian.

Downloading[edit]

Ensure you have the latest server application software. Look above for instructions.

Installing Java[edit]

If you get java: command not found (which may be followed by more text) or if you do have another Java version than 1.6 then you need to install or update java. The official Oracle Java is recommended. A few individuals have experienced issues with OpenJDK. Others report that running on OpenJDK is completely fine.

Debian[edit]

Ensure that the non-free repository is being scanned by apt. You do this by adding non-free to your /etc/apt/sources.list file. e.g.:

deb http://ftp.uk.debian.org/debian/ squeeze main contrib non-free

Update your sources list (as root):

apt-get update

Then to install Java, simply type this in terminal and press enter (as root):

apt-get install sun-java6-jre

Ubuntu[edit]

Unfortunately, some licensing issues have prevented Canonical from allowing repositories to have Sun Java, so you must either download it directly from Oracle, package it, and install it or you could use the PPA provided by webupd8 by following the instructions below.

This guide has been tested on Ubuntu Server 12.10.

Note: You might need to install the package "software-properties-common" by running apt-get install software-properties-common and/or "python-software-properties" by running apt-get install python-software-properties to use the apt-add-repository command.

Run the following commands in this order to add the PPA, update the source list and then install java:
sudo apt-add-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

Then run this to check what version you have installed:
java -version

The output should be similar to:
java version "1.7.0_10"
Java(TM) SE Runtime Environment (build 1.7.0_10-b18)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)

For more information or troubleshooting see this link at webupd8s site

openSUSE[edit]

On older versions, you can simlpy type zypper in java-1_6_0-sun into a terminal.

On newer versions, there is a tutorial here describing how to install Java.

Arch Linux[edit]

Open a terminal and run pacman -S jre7-openjdk as root.

Gentoo[edit]

Use: emerge virtual/jre

Other distros[edit]

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.

If during installation, it asks for a password, enter your password. If you get asked "Is this OK [Y/N]" Enter Y and press enter if required. Java should now be installed.

Start the Minecraft server[edit]

Open the terminal again Applications > Accessories > Terminal Enter the following commands, substituting 'minecraft_server' with the name of the folder you extracted the server to:

cd minecraft_server
java -Xms1G -Xmx1G -jar minecraft_server.jar nogui

Less than 1GB free RAM[edit]

If you have less than 1024MB RAM, the above line may cause problems with swapping and out of memory conditions, which makes the game hard to play.

cd minecraft_server
java -Xms1G -Xmx1G -jar minecraft_server.jar nogui
free -m
It may look like this:

Ram left.PNG

You are interested in the last number in the third line, 2163 in this case. Subtract some RAM as safety. On this computer, the server may use up to 1536 MB RAM. Now, replace the 1024 in the above example with the calculated number:

java -Xms1536M -Xmx1536M -jar minecraft_server.jar nogui

Voila, it should run smoothly now

Tip: If you want to spare more memory, you may set the -Xms parameter even lower, say:

java -Xms32M -Xmx512M -jar minecraft_server.jar nogui

The parameter controls how much memory is reserved on startup Your server will start with 32MB RAM and whenever it needs more memory it will allocate some until it reaches the maximum of 512 MB. However, this will result in a little slowdown whenever the allocation is done.

Startup and maintenance script[edit]

Alternatively you can manage/automate the startup and shutdown of the Minecraft server using a script such as the ones listed below:

Plan 9[edit]

Use: alien-convert <path-to-your-jre->.deb chmod ~/~ rwx for <current user> Then snarf java -jar <path to your .jar> xvmf in acme

Port forwarding[edit]

Port forwarding is used when you have a router and you wish to let users connect to your server through it. If you wish to host your server for local reasons, it is not required that you do so. Keep in mind that port forwarding might cause security risks.

When port forwarding, it varies on how your router will ask you for the information. If you don't understand on how your router wants you to input the information, try visiting PortForward.com for a tutorial. If you still need help, please visit the Minecraft Forums and create a thread asking for help (You need to register).


Once you have managed to locate your router's admin page, and find the Port Forwarding page; hit add new service (may not work) or custom service. When you get a page asking to setup the new rule, it should prompt you on what you want to call it. You may name it as you wish but for simplicity, name it "minecraft". Then you want to look for "type". Select TCP. For the ports (internal and external), enter 25565. If it asks for anything else other than output IP (or internal IP, server IP), leave it alone and continue.

For the out put IP address, use the following steps.

Windows
Locate to your desktop and hit start. From there, either search for cmd, or on previous versions of windows press "run" and type in cmd and hit enter. Once you have completed those steps, a console window should open. From there, enter "ipconfig /all" and press ENTER. From there, you should be given a list of text. Scroll up to Wireless LAN, and look at IPv4 address. On the right should be a couple of numbers, (xxx.xxx.xxx.xxx) copy this down by right clicking the window, and pressing mark; Highlight the area and hit enter. Don't copy any parenthesis or letters.
Mac
The IP location on Mac 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
Either you use the network diagnose center (depending on distribution), or the terminal with ifconfig. The output should return all your interfaces. Search for inet addr:xxx.xxx.xxx.xxx, copy the xxx.xxx.xxx.xxx numbers down.

Once you have this IP, enter it in the "Output IP / Server IP" or what ever way it asks for where the service points to.

Once you have completed it, find where it says to save/continue/apply. And you have successfully port forwarded. When you run your minecraft server, you have to leave the Server IP field empty in the server properties.

For people to connect to your server, they must use your external IP, which you can find at websites such as IP Chicken. If you don't want to use such IPs, use DynDNS services such as NoIP DynDNS

Configure and connect[edit]

Now it is time to configure and connect.


Setting up a VPN[edit]

The contents of this section are not supported by Mojang AB, the Minecraft Wiki, the Minecraft IRC channel or the Minecraft Forums.

An alternate way to set up a server between you and your friends is to set up a VPN (virtual private network). This method may be deemed unrecommended, and an inconvenience for many users due to the fact that all users whom wish to connect to the server must download external software in order to join or create server. An alternative to this method is to port forward. A free software utility that can be used to set this up a VPN is Hamachi by LogMeIn. The free version allows up to 5 connections (i.e. players).

Setting up Hamachi[edit]

  1. Install Hamachi on each computer that wishes to participate in the server, including the host.
    Windows / Mac
    Linux (32-bit and 64-bit .deb and .rpm packages are available, you can install it on Gentoo by emerging "net-misc/logmein-hamachi")
  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.


Configuring the Minecraft server[edit]

  1. Configure the server by editing the server.properties file, the format for which is explained here. Be certain to edit the file with a text editor that does not add formatting (e.g., for italics). Additional configuration may not be necessary as many servers run fine from the default values.
  2. Add your username to the admin.txt and/or ops.txt (newer Minecraft versions may not have an admin.txt file).
    • Ops.txt and admin.txt determine who may execute server commands. In other words, operator ("op") privileges allow you to control certain aspects of the game (e.g., teleporting players).
    • Op privileges may also be granted from the server GUI: type "op <username>" and it will automatically add <username> to the ops.txt file.

Connect to the Minecraft server[edit]

  • 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.
    • 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 (5 for the server, 1 for the client, and remainder for system).
  • Users within your local network (i.e. that are accessing the same router) can connect using your internal IP address - port forwarding is not required for such local connections. The internal IP address of a specific network adapter can be found by typing "ipconfig" into command prompt and looking for the ipv4 address.
  • People connecting from the Internet (i.e., outside of your local network) must connect using your external IP address. You must port forward for someone outside your network to connect to the server.

IP address notes[edit]

  • Unless you set a static IP for the computer that is hosting the game, the internal IP address can change. This affects port forwarding rules, and can make them invalid. Each modem or router has a different way of setting a static IP address. You should refer to the manual for your device(s) or online documentation for further instruction.
  • If you are having players connect to your external IP, your external IP can change if you do not have a static IP from your internet service provider. Use a tool such as MyWANIP 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 DNS 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).

Firewalling, NATs and external IP addresses[edit]

  • You must open the TCP port (default is 25565) on the firewall.
    • If the server in question is not reachable via a globally routable IP address, you will need to add appropriate address and/or port number translation rules to the gateway — usually your router has the global IP address.
  • For help with address translation, opening the firewall and routing (these three make up what people call port mapping/forwarding), portforward.com is a good source. Select your router from that list, skip the ad that comes after selecting the device, 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.

Outdated[edit]

Local network dedicated servers[edit]

This only applies to Classic (v0.30) servers.

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
Example: http://www.minecraft.net/classic/play/4c3bebb1a01816acbe31c5ece1570da5?override=true

Previously, (before the 1.8 beta and website update) this was &override=true. This caused much confusion since the change was not announced by Mojang, and wasn't announced on the website applet pages either. Before the update, connecting to your own URL via the website resulted in red text under the applet window saying "If you can't connect, try this link instead." The link returned the same thing, with the &override=true affixed to the end.

Note: This situation does not effect Beta servers, and you should be able to connect via an internal or external IP.

Video/Alternative Tutorials[edit]

Here are some other tutorials on how to set up a Minecraft server: