Run Minecraft Server on Google Colab
This project sets up a Minecraft server (Paper, Fabric, Forge, or Purpur) on Google Colab using a cloud-based environment. The setup includes Google Drive integration for persistent storage, Java installation, and tunneling for external access.
As the official FAQ says, colaboratory, or “Colab” for short, is a product from Google Research. Colab allows anybody to write and execute arbitrary python code through the browser, and is especially well suited to machine learning, data analysis and education. More technically, Colab is a hosted Jupyter notebook service that requires no setup to use, while providing free access to computing resources including GPUs. In short, it is a vm provided for learning, running python code, machine learning or for general purpose.
Yes, Colab is free to use. But there are some points which, according to me one should keep in mind:
- Though colab is a free service, it shouldn't be exploited indiscriminately or without any care. One should value that its a resource offered for no cost and can get depleted/restricted if the demand increases out of control.
- If it isn't obvious, one shouldn't run mission-critical services (like large and important servers/databases/python programs) on it. Its resources are not guaranteed and not unlimited, and the usage limits sometimes fluctuate. Also, the notebook has a maximum runtime of 12 hours, after which, it should be manually restarted.
- If you need to use it pretty often for intensive tasks, consider purchasing a vps server. A heavy increase in server load would force google to close the service.
- Supports multiple server types: Paper, Fabric, Forge, and Purpur
- Google Drive integration for persistent storage
- Customizable server properties
- Tunneling support to allow external connections
- Open the notebook in google colab.
- Read through the notebook, most of the code is self explanatory. Run the cells which are useful for your use-case.
- Run the second cell which runs the Minecraft server.
- Now you have two options. You can either use Nglocalhost or Pinggy.
- Nglocalhost: Provides a simple and secure way to expose localhost to the internet with minimal setup.
- Pinggy: Offers lightweight, fast, and disposable public URLs for quick local server exposure.
-
Nglocalhost:
- Change
tunnel_service
variable . - You must register the fingerprint if you want a longer duration of tunneling service.
Note: Please include only your key fingerprint. For example:
A27Jcya7a+IE+qAEUZBWExENVnwug0IWgskGqcH1zU0
.- Do not include the "SHA256:" prefix or the "User@DESKTOP" suffix.
- Register the key here
- The key can be found at the following location:
/content/drive/My Drive/Minecraft-server/ssh_keys/id_rsa_fingerprint.txt
- Change
-
Pinggy:
- Change
tunnel_service
variable and follow the script.
- Change
As Google Colab is a VM running Ubuntu server as base OS, it can be easily used as a Minecraft server. Here are the steps which the notebook performs to setup the server:
- Update the system's apt cache.
- Install Openjdk-21 (Java) through apt-get.
- Mount Google Drive to access the minecraft folder (Drive is used here to provide persistent storage).
- Setup Nglocalhost or Pinggy Tunnel (Opening a tunnel at port 25565) depending on the
tunnel_service
variable. - Change directory to the minecraft-server folder on google drive ("Minecraft-server" is the default, located in the root directory of my Google Drive.)
- List/Print the file list on the screen to indicate succesful directory change.
- Startup the Minecraft server (with optimized JVM parameters from Aikar's guide)
Note: Please include only your key fingerprint. For example: A27Jcya7a+IE+qAEUZBWExENVnwug0IWgskGqcH1zU0
.
Do not include the "SHA256:" prefix or the "User@DESKTOP" suffix.
- The key can be found at the following location:
/content/drive/My Drive/Minecraft-server/ssh_keys/id_rsa_fingerprint.txt
- Register the key at if tunnel_service is nglocalhost :
https://nglocalhost.com/subdomain/registration
You can edit server.properties
to customize settings like:
difficulty=hard
max-players=10
online-mode=false
(for cracked servers)server-port=25565
(⚠️ must)
- Server not starting? Check Java version and server logs.
- Tunneling not working? Restart Colab ,rerun the script and check tunnel_log.txt.
- High latency? Google Colab may throttle resources.
- Note: tunnel_log.txt can be found at following location:
/content/drive/My Drive/Minecraft-server/tunnel_log.txt
- If you are using server fabric , Most mods will also require you to install Fabric API into the mods folder.
- If Failed to download server , try reading PaperMc | Fabricmc
- If Tunnel_service does not work, try reading Nglocalhost or pinggy
- Switch between the different tunnel providers and see which works best for you.
- Make regular backups of your world.
- For more Tunneling alternatives read here
- If you want to make your own Server , try reading here
This project is open-source. Feel free to modify and improve!
- Developed by Chaitany Agrawal 🚀
- This project was inspired by MineColab. While the core idea remains similar, all code and implementation details have been independently developed.