Experts insights

How to create a Minecraft VPS server

The Gandi logo, composed of purple blocks reminiscent of Minecraft, with a teal and green background landscape resembling one from Minecraft

Minecraft is a world-building video game with international success and more than 200 million sales since its launch in 2011! Don’t know Minecraft? You can buy the game and try it out.

But if you already know your way around the virtual world, you may want to build your own Minecraft worlds. And for that, you can use Minecraft Realms. However, for complete control over your servers (like, for example, control over installing modpacks), you’ll need your own Minecraft VPS server.

Why create a VPS server?

A VPS server offers greater possibilities than Minecraft Realms for creating your virtual worlds and greater flexibility than a dedicated server. In just a few minutes, you can change the number of CPUs, the amount of RAM, or storage space allocated to your server. At Gandi, getting a VPS server doesn’t require any contractual commitment, so you can host your server for as long (or as little) as you want.

Not only that, you can the Minecraft version that you prefer and which plugins to install (Spigot, Paper, Forge, Fabric, and others).

How to create a Minecraft VPS server in 6 steps

Now we’ll show you the six steps it takes to create a Minecraft VPS server and connect.

1. Create a Minecraft server with Gandi VPS

First off, you’ll need to configure a Minecraft VPS server. For that, navigate to the GandiCloud VPS page on our website, choose the size of your server, and then move on to the payment and configuration steps. You should also create a pair of SSH keys, which will replace your password, to keep your server secure.

Once your server is created, you just need to connect to it.

2. Install Java and Screen for your Minecraft server

The Minecraft server application requires Java Edition. Before creating a Minecraft server, then, you’ll need to be sure to download the most recent version of Java on your VPS server. Once your server is updated, it couldn’t be simpler: just enter this command in your console (on Ubuntu):

apt install openjdk-16-jdk

We can also take the opportunity to install a very useful utility as well: Screen:

apt install screen

3. Configure your VPS server environment

You’ll need to start by creating a dedicated user on your Minecraft instance using the following command:

sudo adduser minecraft --disabled-login --disabled-password

(be sure to verify each step by hitting ENTER/RETURN and then type Y when you are requested to verify).

This user will not be able to connect directly, so you’ll need to use your root user to login by typing the command

su - minecraft

Finally, create a folder called “server” (or you can name it something else) with this user:

mkdir server

And then go into the directory you just created:

cd server

4. Install/download the Minecraft server

Retrieve the download link in the latest version of Java Edition from the official Minecraft server. The version used for this tutorial is version 1.17.1. Here’s the direct link: https://launcher.mojang.com/v1/objects/a16d67e5807f57fc4e550299cf20226194497dc2/server.jar.

Once link is copied to your clipboard, run the command to download it on your server using the command:

wget https://launcher.mojang.com/v1/objects/a16d67e5807f57fc4e550299cf20226194497dc2/server.jar

Warning: depending on the remote server policy, it’s possible that the number of simultaneous logins or the speed of the download will be limited. So be patient and be sure not to interrupt the download, even if it’s not instantaneous. Additionally, we also STRONGLY advise you use official sites when you download archivesto avoid the risk of getting and installing a version containing a worm or backdoor access to your server.

Once you’ve downloaded the file into your server directory, you’ll be able to launch it. You’ll first need accept the terms of use for Mojang.

Then, launch the application for the first time using the following command:

java -Xmx1024M -Xms1024M -jar server.jar

presuming that server.jar is the name of the file you retrieved with the wget command.

You should see several errors, including “[main/WARN]: Failed to load eula.txt.”

Don’t worry, though, it’s perfectly normal. You’ll need to change the value in eula.txt to signify that you accept the terms of use. To do this, staying in the ‘server’ folder, type the following command:

echo "eula=true" > eula.txt

And then relaunch this command:

java -Xmx1024M -Xms1024M -jar server.jar

You server will now launch and you will be able to see a list of commands preparing its configuration. When you see the line ‘[Server thread/INFO]: Done,’ your server will be online and can be used.

You’re not done yet, though. If you close your console now, the server will stop. In Step 2, we installed Screen so that that wouldn’t happen.

Screen will enable you to create a console instance that can be detached from your console and later reattached. This enables you to create the Minecraft server in the same instance, to detach yourself from it and close your console without risk of stopping the server.

Using Screen is relatively simple, but you’ll need to remember a few shortcuts to use it worry free. To begin with, temporarily stop your Minecraft server by typing

/stop

directly in your console.

Now we’ll create a Screen session by typing the command:

screen -S server-mc

The important argument is the capital letter S that means we’re creating a new Session of Screen. The name of the instance will stay secret. In our example, we named the server -mc, but any other name would have worked. It’s just important that you remember that name.

A new console screen will open. Relaunch your server with the same command as previously:

java -Xmx1024M -Xms1024M -jar server.jar

Once your server is properly launched, you can detach your Screen instance and close your console, if you want, without stopping your server.

To detach your Screen instance while keeping your server running, hold CTRL, then A, then D. You should see a new screen that references this operation, for example: [detached from 12345.minecraft].

You can quit your console without risk of lowing your Minecraft server.

To return to the server session, you just need to type the following command:

screen -r server-mc

presuming the session name is server-mc like in our example. Here, the argument -r reattaches your console to the session.

If you want to stop your Minecraft server, just use the command /stop in the active server console.

Going further

If you want to modify certain server settings, like for example, activating or deactivating PvP mode, modifying the difficulty or the maximum number of players, you’ll need to edit the ‘server.properties‘ file, which can be found in the root of the director ‘server.’

You’ll need to update the text in the file using editors like VI, ViM, or Nano, which may seem complicated at first. Be sure to master at least the basic commands of these editors before saving any changes that you might make to your file, or risk not being able to launch your server.

5. Open your Minecraft VPS server’s port

In order for your server to be visible to the outside world, you’ll need to open a specific port for your server. You can do this with the following command using the ‘root’ user:

/sbin/iptables -A INPUT -p tcp --dport 25565 -m state NEW -j ACCEPT

Once you’ve entered the command, you can return to your dedicated Minecraft user. Your server should then be available to the outside.

6. Launch/join your server/Connect to your Minecraft VPS server

If your server has been launched and is active on your Gandi VPS and you’ve successfully opened port 25565,you can now connect to it. In your Java Minecraft client, go to the “Multiplayer” tab, then “Add server,” and choose the name that you want in “Server name” (“My Gandi server,” for example).

Then, in “Server Address,” just enter the IP address of your Gandi server, validate, and click on Done. And there you have it! You should see your server connected and you should then be able to join it!