Skip to content
Related Articles
Get the best out of our app
Open App

Related Articles

Google Cloud Platform – Setting Up a Game Server

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

In this article, we will set up a server in a public cloud to serve a game application by using infrastructure as a service (IaaS) provided by the google cloud platform. However, the process will be nearly the same for any other public cloud platforms.

Overview of steps:

  1. Set up the account and create the project in any public cloud (say, Google cloud platform)
  2. Create a virtual machine of the required configuration and disk boot image in the preferred region and zone(say, Debian GNU/Linux 9 (stretch)  machine with at least 50 GB disk size )
  3. Install all the run time requirements  and dependencies  in the virtual machine (say JRE for java application)
  4. Set up the firewall rules for the virtual instance to allow client traffic.
  5. Make sure the server is running all the time.

Tools Used:

In this article, we will the following tools and technologies:

Now follow the below steps to set up the server.


  • Go to Google cloud console  
  • Signup using Google account, then create the project  by clicking the select project dropdown on the top bar, then clicking on a new project 

Note: If you do not have a free trial account activated you will be billed for provisioning and using any resources in Google cloud 

After the initial setup is done you must see a similar interface:

Note: We are using the Qwiklabs practice account here.


In this step we have to create VM instance with the required configuration and we will also add an additional SSD persistent disk of 50GB. Open Google cloud shell by clicking on the below-shown button:

  • Click continue or authorize if asked,
  • Enter the following command, to create the instance
$ gcloud beta compute --project=qwiklabs-gcp-04-f7bbc9a0604c instances create mc-server
 --zone=us-central1-a --machine-type=e2-medium --subnet=default --address= 
 --network-tier=PREMIUM --maintenance-policy=MIGRATE 
 --scopes=,,,,, --tags=minecraft-server --image=debian-9-stretch-v20201216 --image-project=debian-cloud --boot-disk-size=10GB --boot-disk-type=pd-standard --boot-disk-device-name=mc-server --create-disk=mode=rw,size=50,type=projects/qwiklabs-gcp-04-f7bbc9a0604c/zones/us-central1-a/diskTypes/pd-ssd,name=minecraft-disk,device-name=minecraft-disk --reservation-affinity=any

It might take about a minute,  Output must look like this:

  • After the command is executed, On the navigation bar, go to Compute Engine > VM instances

Note: The “external IP addresses” of the virtual machine will be used to check the working of the server.

  • Click SSH to open a terminal and connect. (it will open the new window)

As we have added a disk, we have to mount the disk by using the following commands in the Linux instance.

  • To create a directory that serves as the mount point for the data disk, run the following command:
$ sudo mkdir -p /home/minecraft
  • To format the disk, run the following command:
$ sudo mkfs.ext4 -F -E lazy_itable_init=0,\
lazy_journal_init=0,discard \
  • To mount the disk, run the following command:
$ sudo mount -o discard,defaults /dev/disk/by-id/google-minecraft-disk /home/minecraft


  • To update the Debian repositories on the VM, run the following command:
$ sudo apt-get update
  • After the repositories are updated, to install the headless JRE, run the following command:
$ sudo apt-get install -y default-jre-headless
  • To navigate to the directory where the persistent disk is mounted, run the following command:
$ cd /home/minecraft

The wget is used to download the JAR file. 

  • To install wget, run the following command:
sudo apt-get install wget
  • If prompted to continue, type Y
  • To download the current Minecraft server JAR file (1.11.2 JAR), run the following command:
$ sudo wget

  • To initialize the Minecraft server, run the following command:
$ sudo java -Xmx1024M -Xms1024M -jar server.jar nogui

We have to accept the End User Licensing Agreement (EULA), in order to run the server.

  • To edit the EULA, run the following command:
$ sudo nano eula.txt
# Change the last line of the file from eula=false to eula=true

After editing eula.txt, it must look like this:


  • To save & exit the Nano text editor press CTRL+o, Enter,  CTRL+x

.STEP 4: 

  • Go to Google cloud terminal in the console and enter the following command to create the firewall rule,
$ gcloud compute --project=qwiklabs-gcp-04-f7bbc9a0604c 
firewall-rules create minecraft-rule --direction=INGRESS 
--priority=1000 --network=default --action=ALLOW --rules=tcp:25565 
--source-ranges= --target-tags=minecraft-server

The output must look like this:


To make sure  that the server runs all the time, we can use the “screen” application.

  • Now go again to virtual machine SSH session and install “Screen” application using the below command:
$ sudo apt-get install -y screen
  • To start your Minecraft server in a screen virtual terminal, run the following command: (Use the -S flag to name your terminal mcs)
$ sudo screen -S mcs java -Xmx1024M -Xms1024M -jar server.jar nogui

It will take some time to start the server. The output must look like this:

Now the server will continue to run in the background,

  • Use this website to check whether the Minecraft server was working or not.

Working server-status must be similar to the image shown below:

Note: You have to use your virtual machine external IP address,  (Go to Navigation menu > compute Engine > virtual Instances, to get your virtual machine external IP address).

My Personal Notes arrow_drop_up
Last Updated : 04 Jan, 2021
Like Article
Save Article
Similar Reads