I’m not a gamer, but I have an offspring who is deeply obsessed with Minecraft. I set up a Minecraft server for her so that she can play with her friends online in a safe environment.
⚠️ I’m focusing on the Java edition of Minecraft. If you’re a Bedrock user and would like to collaborate with me on a server setup, please get in touch!
You can run the server on a local machine (laptop or desktop) or a cloud server. I’ll consider both options here. If you’re going the (headless) cloud server route then I’d suggest something at least like a
t3.small EC2 instance, which should have enough beef to handle a few concurrent clients.
If you are going to run the Minecraft server on a machine with limited RAM then you might want to add swap space.
Since the Minescraft server is a Java application you’ll need to install a Java Runtime Environment (JRE). First update the APT package source list.
sudo apt update
Then install the JRE package. Choose whichever option is appropriate to your server.
# Desktop Server
sudo apt install -y openjdk-18-jre
# Headless (Cloud) Server
sudo apt install -y openjdk-18-jre-headless
You’ll need to ensure that the Minecraft clients are able to access the server. On the Desktop Server you’ll add a firewall rule.
sudo ufw allow 25565
On the Headless Server ensure that there is a suitable rule in place to allow inbound connections on port 25565.
Minecraft Server Download
Go to the Minecraft server download page and download the server package. On the Desktop Server you can simply trigger the download via your browser. On the Headless Server you’ll need to use a CLI tool like
wget. Get the URL for the most recent server release from the link above.
Accept the EULA
Create a file called
eula.txt with the following content:
Now launch the server. You can take the headless approach on both Desktop or Headless machines, but on Desktop machine you might also want to be able to see Minecraft server UI. There’s not too much to be gained by that though because it’s not very informative.
# Desktop Server
java -Xms1024M -Xmx1024M -jar server.jar
# Headless Server
java -Xms1024M -Xmx1024M -jar server.jar nogui
While the server is launching there will be copious logs on the terminal. It will look something like this (aggressively redacted):
[Server thread/INFO]: Starting minecraft server version 1.20.4
[Server thread/INFO]: Loading properties
[Server thread/INFO]: Default game type: SURVIVAL
[Server thread/INFO]: Generating keypair
[Server thread/INFO]: Starting Minecraft server on *:25565
[Server thread/INFO]: Using epoll channel type
[Server thread/INFO]: Preparing level "world"
[Server thread/INFO]: Preparing start region for dimension minecraft:overworld
[Server thread/INFO]: Time elapsed: 8589 ms
[Server thread/INFO]: Done (17.062s)! For help, type "help"
You’re going to need to have the server’s IP address in order to connect from the Minecraft client. Either get this from the EC2 console for Headless or via the terminal for Desktop:
You can tweak a variety of server configuration options via the
Security & Limiting Access
You can make your Minecraft server more secure by moving it to a non-standard port. Edit the configuration file and choose an alternative port:
You’ll need to ensure that inbound access is allowed on this port (as we did above for the default port).
This is not a particulary robust solution to securing the server but it will reduce the likelihood of your server being discovered by somebody looking for machines accepting connections on the default Minecraft port.
You can choose the default game mode by editing the
Valid options are:
Operator Permission Level
An operator is a player with elevated privileges. It’s something like an admin user. There are four operator levels:
- Basic — Bypass spawn protection.
- Single player — Use
/tpand can edit command blocks.
- Multi-player — Use
- Server — Use
op-permission-level property determines which of these levels applies to operators.
You might find it useful to update the values for these properties too:
online-mode(useful for offline or LAN-only servers) and
white-list(a list of players who can connect to the server).
You can interact with the running server via the console.
Giving commands directly to the server is somewhat different from giving commands in the client since you’re not actually playing the game. Some commands will require you to specify a username. For example, to change the game mode for a specific player:
/gamemode creative datawookie
Of course it’d be easier if the players themselves could make the change. In order for that to be possible you need to enable cheats, which is done by making a player into an operator. See notes on operator permission level.
You can then disable cheats again later.
If you want the server to continue running after you have disconnected the terminal then you’ll either want to launch it in the background using
nohup or run it in a
world/ directory or (2) edit
server.properties and provide a new value for
level-name. Then restart the server.
Once the server is up and running you can connect to it from a Minecraft client.