2

How can I run a Minecraft Bedrock Dedicated Server (Ubuntu version) on macOS Big Sur?

I need the server to run while still running macOS (I don't want to install Ubuntu as my main OS).

I also would like the server to keep running without my screen being on.

tjcaul
  • 283

2 Answers2

3

After a few hours of frustration, I now have a Minecraft Bedrock server (Ubuntu version) running on an Intel MacBook Pro. I thought I would post my process here for others and my future self.

Requirements

  • A Mac computer running macOS Big Sur (11.x) — older or newer versions may work; I have not tested on other versions. You must have administrator access — if you own the computer, you probably do.
  • A router you own and a decent internet plan (you must be able to access the router’s web panel; if it’s yours, your probably can)
  • Consistent access to a power outlet (your server machine will need to stay plugged in when running)

Downloading Software

It may be time-efficient to begin another download before the first download has finished.

  1. Download the Ubuntu Server .iso file — make sure to select Option 2: Manual server installation
  2. Go to virtualbox.org and click the large Download VirtualBox button, then the OS X Hosts link, or download directly (you can also run wget https://download.virtualbox.org/virtualbox/6.1.18/VirtualBox-6.1.18-142142-OSX.dmg -O ~/Downloads/VirtualBox.dmg in the Terminal)

Installing Software

Navigate to your Downloads folder (or wherever you chose to save the downloaded files, if it was elsewhere) and open the VirtualBox .dmg file. Follow the instructions to install VirtualBox.

Creating the Virtual Machine

Open VirtualBox from the Launchpad or your Applications folder, then click the star labelled New. Fill out the fields as follows:

Name: [Whatever you want to call the server; can be changed later]

Machine Folder: [Leave as-is]

Type: Linux

Version: Ubuntu (64-bit)

Choose memory size

Click Continue. For the initial installation, I recommend allocating as much as possible. If you don’t know how much memory you have, choose  > About This Mac in the Menu Bar and look at the Memory heading. Then, set the memory in VirtualBox to half of your total RAM (it will likely be displayed in MB, so convert from GB to MB by multiplying by 1024).

Create a virtual disk

On the next page, select: Create a virtual hard disk now, Create, VDI, Continue, Dynamically allocated, Continue.

Leave the text field (the folder for the virtual disk) as-is. If you’re tight on storage space, a disk size as small as 6 GB may be adequate. If you’re going to have a lot of players exploring a lot of the world, 10 or 12 GB may be a good size. When setting the size, try to keep it to an even size; don’t use 9.62 GB, for example. Once you’ve chosen your disk size, click Create.

More settings

If it’s not already selected, select your newly created virtual machine in the panel on the left. Click the orange Settings gear at the top of the window.

First, go to System > Processor and set the number of CPUs to one less than the number of cores your computer has. If you don’t know, check in  > About This Mac and look at the Processor heading. The processor should have a number of “cores” (Dual is 2, Quad is 4). Make sure the Execution Cap is set to 100%.

Under Storage, select the CD/DVD icon with the word “Empty” in the left panel. In the right panel, select the small disk icon (Optical Drive) and click Choose a disk file…. Navigate to your Downloads folder, and select the Ubuntu Server .iso file. Click Open.

Under Network, make sure Enable Network Adapter is checked, and Attached to is set to NAT. Click Advanced, then Port Forwarding. Set up three entries: | Name | Protocol | Host IP | Host Port | Guest IP | Guest Port | |-----:|:--------:|:---------------:|----------------------------------------|:---------------:|------------| | ssh | TCP | [Leave blank] | [A random large number, 2222 is good] | [Leave blank] | 22 | | mc | UDP | [Leave blank] | 19132 | [Leave Blank] | 19132 | | mc6 | UDP | [Leave blank] | 19133 | [Leave Blank] | 19133 |

Click OK twice.

Installing Ubuntu Server

Warning: this is very resource-intensive. Close all other open apps (although it may be helpful to have Activity Monitor open). Put your computer in a well-ventilated place if it’s a laptop. Connect the power cable if it’s a laptop, even if the battery is fully charged. Expect heat and noise.

Select the green arrow (Start) at the top of the window. Switch to the window that appears. You can minimize of hide the main VirtualBox window. In the VM window, select View > Scaled Mode in the Menu Bar. Resize the window so the text is easily readable. Close the pop-ups at the top of the VM window.

Once you see a language selection screen, select your chosen language using the arrow keys and the space bar or return key. Obviously, this tutorial is in English, so if you select another language, you will have to translate the titles and options I refer to.

If you’re not using an English (US) keyboard layout, use the arrow keys and space bar / return key to change your layout. Navigate to the bottom and select [Done].

The default settings should be good enough, so continue selecting [Done] until you see a panel titled Confirm destructive action. This means that your virtual hard disk — the one you just created in VirtualBox — will be wiped. Since you don’t have any data on it, this is okay. Select [Continue].

Set your name, server name, username, and password to whatever you want. Of course, you should remember all of these. Select [Done].

Select Install OpenSSH server so there is an X in the box. You do not need to change the other fields. Select [Done].

On the next screen, do not select any packages. You probably don’t need them. Just select [Done].

Wait. This may take a while. On my first run-through, I made the mistake of only allocating 1 core and 1GB of RAM. If you did that in the setup stage, you may have to wait a couple hours. With 3 cores of an i5 and 4 GB of RAM allocated, the installation process only took 20 minutes. If your fans (if you have them) go crazy and/or your computer gets very hot, select Machine > Pause in the Menu Bar, and resume the machine’s execution with the same menu bar item once the computer calms down. Trust me, this pausing system is much better than not giving the machine enough resources to keep it slow.

Once the [Reboot Now] option appears at the bottom of the screen, select it. Your VM should restart. Wait for the scrolling text to finish, and login with the username and password you chose earlier. Then, run sudo shutdown now. Enter your password. Once the VM window disappears, go back to the main VirtualBox window.

More settings

Since the installation is done, you should probably decrease the resources allocated to it; a server with a few people playing only doesn’t need many GB of RAM and 3 cores. Unless your computer’s only purpose is as a server machine, decreasing resource allocation will make it quieter and nicer to use for other purposes. On a quad-core, 8 GB computer, I gave the machine 2 cores and 2 GB of RAM.

SSH-ing into the server

With the settings changed, you can now run the machine again. This time, click the small arrow beside the Start button and select Headless Start. This time, a window won’t open. In the preview pane, look at the tiny scrolling text. When there are only 2 lines, the first longer than the second, open a window of the Terminal app. Remember the port you chose earlier in the Port Forwarding setup (I suggested 2222)? You need that now. You also need the username you chose. In the Terminal, run ssh <user>@localhost -p <port>. You should be asked for a password within a few seconds. Enter the password you chose. You are now connected to the server via SSH. It’s the exact same as the viewer window you used before: you can run commands, see the prompt, and see output. This way, you can disconnect from the server and leave it running, without an app or window being open. It is also easier on the processor and memory, since the server doesn’t have to check for terminal input and send output if you’re not connected to it; it just runs silently in the background. To disconnect from the server, just type exit. You can connect to the server at any time using the ssh command from before.

Getting the Bedrock Server

Now, you need the Minecraft server software. Go to https://www.minecraft.net/download/server/bedrock and choose the Ubuntu version. You can also download directly at https://minecraft.azureedge.net/bin-linux/bedrock-server-1.16.210.06.zip, or run wget https://minecraft.azureedge.net/bin-linux/bedrock-server-1.16.210.06.zip in the server. If you don’t use wget, you have to get the .zip file from your computer to the server. Fortunately, that’s easy. Run the ssh command in your computer’s terminal, replacing ssh with sftp: sftp <user>@localhost -p <port>. Instead of SSH-ing into the server, you are now connected via SFTP (Secure File Transfer Protocol). Use the following commands to transfer the file from your computer to the server:

lcd ~/Downloads to change the local folder to Downloads

put <name of bedrock server .zip file> to send the file to the server

bye to quit the SFTP session

Running the server

Now, SSH into the server. Use the tmux command to start a tmux session. This will allow the server to keep running even after you exit the SSH session.

Follow the instructions in the bedrock_server_how_to.html file to start your server. If you don’t want to change any settings, that means you just run LD_LIBRARY_PATH=. ./bedrock_server. Then, detach the tmux session: hold the control (not command) key end press B, then release control and hit D. In other words: ^B D. Now you can exit the ssh session, too.

Your server is now running. However, you probably can’t connect to it.

Port Forwarding

Every router is different, so I can’t give great instructions. You may need to look up the process for your specific router. First, go to your router’s address in a web browser. This may be 192.168.0.1. Alternatively, go to your public IP address (can be found at whatismyip.com). Log in to your router web panel. The credentials are probably printed on a sticker on your router. You’ll need to find your computer’s private address. Your router panel should have a section to find connected devices; look for yours in the list. It’ll be something like 192.168.0.10. In the port forwarding menu, add three new rules. The format probably won’t be exactly how I display it.

Name: MCServer-SSH, Protocol: TCP, Public Port: 2222 (Or whatever you chose earlier), Private Port: 2222 (“ “), Private Address: Your computer’s private address, Public Address: Any

Name: MCServer, Protocol: UDP, Public Port: 19132, Private Port: 19132, Private Address: Your computer’s private address, Public Address: Any

Name: MCServer6, Protocol: UDP, Public Port: 19133, Private Port: 19133, Private Address: Your computer’s private address, Public Address: Any

Mine looked like this:

MCServer-SSH, TCP, 2295, 2295, 192.168.0.10, Any

MCServer, UDP, 19132, 19132, 192.168.0.10, Any

MCServer6, UDP, 19133, 19133, 192.168.0.10, Any

Now, you’ll need to open Minecraft on another device. You can’t play on your server from your computer, unfortunately.

Add a server to your server list. Use your public IP as the address, and 19132 (the default) as the port.

Hopefully, hopefully, you can connect.

Going forward

Controlling the server

Now that you port-forwarded the router, you should be able to ssh from any device, including iOS devices (using an SSH client). Use your username, public IP, and port 2222 (or whatever you chose). You can add public-key authentication to allow password less sign-in, but that is out of the scope of this tutorial. When SSHed into the server, run tmux attach to connect the the tmux session. From there, you can run server commands and stop the server. Just remember: detach from tmux before using exit.

Starting the server

To start the server, ssh to it, open a tmux session, and run LD_LIBRARY_PATH=. ./bedrock_server. You can create an alias in a bashrc file to do this more easily; I just run server to start my server.

Customizing the server

You can follow the instructions in the bedrock_server_how_to.html file to change your server’s preferences.

Keeping the server running

If you want your server running constantly, you need to prevent your computer from sleeping. However, you need the display to turn off, or you will waste a lot of electricity, and may decrease the life of your screen. If you’re not using a laptop or you’re fine with leaving a laptop open, change the settings in System Preferences > Battery > Power Adapter to prevent the computer from sleeping when the display is off. That way instead of putting your computer to sleep, you can just lock it and turn off the display with a hot corner, keyboard shortcut, or touch bar button. But if you put it to sleep, the server will disconnect all players. Once you wake it up, the server will continue running. If you’re using a laptop, you can run sudo pmset -a disablesleep 1 to prevent it from sleeping when the lid is closed. However, that means it will never sleep unless you directly put it to sleep from the menu bar. If you want normal sleep behaviour to resume, run sudo pmset -a disablesleep 0.

Conclusion

If, somehow, I wrote everything correctly and didn’t miss any steps, and you followed all the steps correctly, and your computer doesn’t have a different configuration than mine, your server should hopefully work. I have a small personal server that can easily handle everyone I know who plays Minecraft. My computer is still usable otherwise, and there is no maintenance for the server other than starting it when I reboot my computer, and that could be automated. It doesn’t stop when I close the lid. I don’t expect it will work quite as well for you, but I hope this tutorial helped you get at least part of it set up. If you have a problem with your server, feel free to ask questions.

tjcaul
  • 283
1

Docker is your best bet. Also easier to configure and you'll be able to squeeze much more performance of your server comparing to VB.

There’s a great container that I use: https://hub.docker.com/r/itzg/minecraft-bedrock-server

I’ve been running a Bedrock server since 2019 on a spare MacMini (macOS High Sierra with 4GB RAM!) have a nice little, international community built around it over the years (always the same world :-).

Up to Minecraft version 1.18 it was kinda playable for few players at the same time but 4GB ram and an old i5 processor are no longer up to the task I’m afraid. I am trying to get it working on my old i7 macbook pro now but facing some networking issues.

Having said that you will need to tinker with the network settings a bit to get the server working on a Mac, especially if you want it to be accessible over internet. The Github project maintainer and other contributors always been supper-helpful tho. https://github.com/itzg/docker-minecraft-bedrock-server

Matt Rek
  • 106
  • 11