Minecraft has been around for years now but it still remains the most popular game played online. While there are some commercial services providing access to Minecraft gaming servers, it is also possible to setup your own server for at a very price. This in-depth tutorial will show you how to do this.

Let’s get started!

Choosing a Dedicated Hosting Provider

In order to setup a Minecraft server, you will need to get a dedicated server first. There are two options available: virtual private servers and dedicated servers. A virtual private server, also known as a VPS, offers all the flexibility of a dedicated server at a fraction of the cost. However, the virtualization layer can make virtual servers a bit slower than a physical dedicated server.

It is also important to note that some virtualization platforms, such as Virtuozzo, may cause some latency. If you choose to get a virtual server, make sure to get a KVM or a Xen VPS as these virtualization technologies allows direct access to the host server’s hardware.

Recommended Minecraft Cloud VPS Services

When choosing a VPS hosting provider to host your Minecraft server, it’s important to select a location as close as possible to your physical location. The Minecraft Server software also requires a minimum of 1 GB RAM.

Here are our top three (3) recommendations:

ProviderCPU CoresRAMLocationsPrice From
Vultr11 GBUS, Canada, Europe, Australia and Asia$5/mo.
DigitalOcean11 GBUS, Canada, Europe and Asia$10/mo.
Linode11 GBUS, Canada, Europe and Asia$5/mo.

Be sure to browse our exclusive deals on VPS hosting before you make a purchase.

Recommended Minecraft Dedicated Servers

If you are planning to host a high-traffic Minecraft server with lots of users, you might want to get a dedicated server instead. A physical dedicated server can provide you with much more performance and will eliminate the overhead from the virtualization layer a VPS has.

ProviderCPURAMLocationsPrice From
TurnKey InternetDual Intel Xeon X5650 2.66 GHz32 GBUS$53/mo.
A2 HostingIntel 3.1+ GHz 2 Cores8 GBUS$99/mo.
LiquidWebIntel Xeon E3-1271 v3 4 Cores @ 3.6 GHz8 GBUS and Europe$159/mo.
WHUKIntel Xeon E3-1220v5 3.0GHz8 GBUK£69.99/mo.

You might want to check our dedicated hosting deals before you order a dedicated server though.

Deploying a New Cloud VPS

For this tutorial, I will be using a Ubuntu VPS from Vultr. To get started, head over to https://www.vultr.com/ and enter your email address and a password to create your account.

Once your account has been created, go to your Vultr control panel (https://my.vultr.com/) and click on Servers > Instances > Deploy one.

minecraft vultr deploy server

On the next page, select the desired location for your Minecraft server:

Vultr - New Cloud Instance Location

Set the server type to the latest version of Ubuntu, a Linux operating system:

ubuntu cloud vps

For the server size, make sure to select a plan that has at least 1GB of RAM (that’s 1024MB of memory). Leave the next options to their default values and skip to step 7 to set the hostname and label for your new server.

The hostname must be part of a domain name you already own. This is essential if you want to access your server by its hostname. Otherwise you’ll have to access it by its IP address.

vultr instance hostname

When you are done, hit the Deploy Now button. Deploying the new instance will take approximately 1 minute.

Accessing Your Cloud Server

When your new cloud server is ready, click on Manage:

On the next page, note down the IP address as well as the root password of the server:

server ip and password

To access the server, you will need an SSH client such as Putty which you can download here. Once you’ve installed Putty, launch it and enter the IP address of your Vultr cloud server. Click on Open to establish the connection:

The first time you connect to your server, you’ll get a security alert from Putty. Just click on Yes to confirm that you trust this host.

When you’re prompted for the login credentials, use root as the login and enter the password you previously got from the control panel:

ubuntu shell putty

Preparing the Server

It is strongly recommended that you change your root password before going any further. To do so, use the passwd command:

ubuntu change user password

Next, we need to update the packages already installed. Type this command:

apt-get update

In order to install the Minecraft Server, you will need to install the Java Development Kit. Use this command:

apt-get install default-jdk joe

While the “joe” package is optional, it provides a text editor that is much easier to use than “vi”.

It’s always best to avoid running applications as the root user so we’ll create a regular user account. User the adduser command to proceed:

adduser minecraft

If you are not prompted for the password during the user creation process, set it manually:

passwd minecraft

Now we’re going to create a swap file. This especially important if you’re running a VPS with low memory (2GB and less). First, make sure there isn’t already a swap file in place:

swapon --show

If there’s no output, then you can proceed with the swap file creation. Start by creating a file that is twice the size of your server’s RAM. In this case, since we have 1GB of RAM, we’ll create a 2GB swap file:

fallocate -l 2G /swapfile

Set the permissions on /swapfile :

chmod 600 /swapfile

Mark the file as swap:

mkswap /swapfile

Enable the swap file:

swapon /swapfile

Make the swap file permanent:

cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | tee -a /etc/fstab

Now we’ll do a little bit of tweaking to force the server to use the swap file only when absolutely necessary:

sysctl vm.swappiness=10

Make this configuration change permanent by editing /etc/sysctl.conf:

joe /etc/sysctl.conf

Add this line at the end of the file:

vm.swappiness=10

Now save the file and exit the editor using CTRL+K, X. You are now ready to proceed with the game server installation.

Installing the Minecraft Server Software

Like mentionned earlier, I don’t like running applications using the root account so we’ll switch to the “minecraft” account we created in the previous step:

su - minecraft

You can now see from the shell prompt that you’re no longer the root user:

minecraft@minecraft:~$

At this point, you’re current working directory is /home/minecraft

Go to https://minecraft.net/en-us/download/server to find out what is the latest Minecraft Server version and download the Java Archive to your server:

wget -O minecraft_svr.jar https://s3.amazonaws.com/Minecraft.Download/versions/1.11.2/minecraft_server.1.11.2.jar

Next we need to start the server manually one time:

java -Xmx1024M -Xms1024M -jar minecraft_svr.jar nogui

The Minecraft server will not start properly and it’s totally normal:

Minecraft Server EULA

Upon its first execution, the Minecraft Server will create a file named eula.txt in the same directory as the JAR file. You need to edit it:

joe eula.txt

Now change the value of the eula parameter to TRUE:

minecraft server eula true

Do a CTRL+K, X to save the file and exit the Joe editor. Now try to start the Minecraft Server again:

java -Xmx1024M -Xms1024M -jar minecraft_svr.jar nogui

The server will now start to dump the output to the screen and it should look something like this:

minecraft server output log

While we’re not done yet, you can try to connect to the server right away. Simply launch the Minecraft game and click on Multiplayer from the main screen:

minecraft multiplayer server

On the next screen, click on Add Server and enter a name and the IP address of your newly installed server:

minecraft add server

If everything went well, you should now see a connection to the Minecraft server:

minecraft game server status

Now close the Minecraft game and hit CTRL+C in your Putty console to stop the Minecraft server.

Running the Minecraft Server as a Service

Even though you could use your new Minecraft server right away, it is preferable to execute it as a service. This will prevent the game server from crashing if ever the shell connection to the server was terminated. Let’s start this by going back to the root shell by exiting the minecraft session:

exit

Your command prompt should now be set to root@[hostname].

To run the Minecraft server as a systemd service, we’ll create a startup script in /etc/systemd/system like this:

joe /etc/systemd/system/minecraft-server.service

Now add this content to the script (credit: Gamepedia.com):

[Unit] 
Description=start and stop the minecraft-server

[Service]
WorkingDirectory=/home/minecraft
User=minecraft
Group=minecraft
Restart=on-failure
RestartSec=20 5
ExecStart=/usr/bin/java -Xms1024M -Xmx1024M -jar minecraft_srv.jar nogui

[Install]
WantedBy=multi-user.target

Now save the script and exit the editor by hitting CTRL+K and then X. To start the service automatically at boot, type:

systemctl enable minecraft-server

Then start the Minecraft server manually:

systemctl start minecraft-server

To stop the Minecraft server manually:

systemctl stop minecraft-server

And if you ever need to stop the Minecraft server from running automatically at boot, type:

systemctl disable minecraft-server

If you want to verify that the Minecraft server is running, type this command:

ps aux | grep minecraft

Look for the following process:

minecraft server process

You should now be able to connect to the Minecraft server when starting a multiplayer game.

Securing Your Minecraft Server

At this point, your server is accessible to anyone and is prone to attacks (at the operating system level).

Here are a few tips to secure your server:

1. Change the SSH Port

The default SSH port is set to 22. It is recommended to change this to another (unused) port to avoid being detected by network scanners. To do this, edit /etc/ssh/sshd_config as root:

joe /etc/ssh/sshd_config

Find the Port parameter and change its value. Here’s a list of commonly used ports you want to avoid using.

# What ports, IPs and protocols we listen for
Port 2020

Don’t exit the editor yet. We now want to disable the root login. Find the following line:

PermitRootLogin yes

And change it to:

PermitRootLogin no

Now disable DNS. Find this line:

UseDNS yes

Change it to:

UseDNS no

If it doesn’t exist, add it as a new line anywhere in the file. Hit CTRL+K and then X to save the configuration file and exit the editor.

Now restart the SSH daemon:

systemctl restart sshd

The next time you use Putty to connect to your server, don’t forget to use the newly specified port. It is also important to note that you will be no longer to login as root. To become the root user, you will first need to login with the “minecraft” account and then use this command to become root:

su - root

2. Install a Firewall

To protect your Minecraft server from intrusions, it is recommended to install a firewall such as CSF. We’ve already wrote a tutorial on how to install CSF but before you do so, here some packages you need to install first:

apt-get install sendmail zip perl libwww-perl

To do so, follow steps #3 to #5 from this tutorial. While we initially wrote it for CentOS 7, it will also work fine on a Ubuntu server.

Once you’ve installed CSF, make sure to enable connections to the Minecraft server port. To do so, start by finding out on which port the Minecraft server is listening:

cat /home/minecraft/server.properties | grep server-port

This will output something like:

server-port=25565

Now add this port number to /etc/csf/csf.conf:

joe /etc/csf/csf.conf

Find the line that begins with:

TCP_IN = 

And add the port number to the list:

TCP_IN = "20,21,22,25,53,80,110,143,443,465,587,993,995,2020,25565"

Now save the configuration file and exit the editor (CTRL+K, X) and restart CSF:

csf -r

3. Secure Your Minecraft Server Using a White-list

Unless you plan on making your Minecraft server public, it is recommended to add users you want to allow to the white-list. To do so, edit /home/server.properties (logged in as the minecraft user, not as root!) and set the white-list parameter value to true.

joe /home/server.properties

Find:

white-list=false

Change it to:

white-list=true

Save the file and exist the editor. Now edit whitelist.json:

joe /home/minecraft/whitelist.json

And add users as follow:

[

   {

      "uuid": "xxxxx-xxx-xxxxx-xxxx",

      "name": "username"

   },

   {

      "uuid": "xxxxx-xxx-xxxxx-xxxx",

      "name": "username2"

   }
]

You can use this tool to find your the UUID associated with your Minecraft account: https://mcuuid.net/

Don’t forget to restart the Minecraft Server service after making some changes:

systemctl restart minecraft-server

You are now set to play Minecraft online using your own server. Feel free to submit your comments below!

tracking pixel

Is your website slow?

Enter its URL below to find out now:

About the Author

Leave a Reply

Your email address will not be published. Required fields are marked *