
Host a free Minecraft server using Google Colab.
This repository provides a Google Colab notebook for setting up and running a Minecraft server with SSH tunneling. This allows you to host a Minecraft server directly from your Google Colab environment, accessible to others via a public IP address.
Note: Remember to replace YOUR_USERNAME and YOUR_REPOSITORY_NAME in the "Open In Colab" badge link above with your actual GitHub username and repository name.
portmap.io to create an SSH reverse tunnel, making your server accessible from outside Google Colab.Before running the notebook, ensure you have the following:
qasw1234.first.pem) is required for SSH tunneling. This file should be placed in the /content/drive/MyDrive/ms/ directory.portmap.io to set up the SSH tunnel.Follow these steps to set up and run your Minecraft server:
These steps only need to be performed once.
Minecraft_hosting.ipynb file to Google Colab.!sudo apt purge openjdk-* -y and !sudo apt autoremove -y to ensure no conflicting Java versions are present./content/drive/MyDrive/ms directory. This is where your Minecraft server files will be stored.server.jar for Minecraft version 1.21.3.qasw1234.first.pem) is placed inside /content/drive/MyDrive/ms/.These steps need to be performed every time you want to start your Minecraft server.
/content/drive/MyDrive/ms and set the correct permissions for your SSH key file (chmod 600 your_key_file.pem).session.lock file to prevent startup issues.portmap.io endpoint to your local Minecraft server port localhost:25565.To create the necessary SSH tunnel for your Minecraft server, follow these steps on Portmap.io:
qasw1234.first.pem).61819).localhost.25565 (the default Minecraft server port).TCP.your_username-your_port.portmap.io:your_port (e.g., demo.portmap.io:61819). You'll use this information in the SSH command within the Colab notebook.[MC]) and the SSH tunnel (prefixed with [SSH]).exit in the input prompt and press Enter to gracefully stop the Minecraft server and the SSH tunnel.Once the server is running and the SSH tunnel is active, your Minecraft server should be accessible at the Public Host and Public Port provided by your Portmap.io mapping (e.g., demo.portmap.io:61819). This address maps to localhost:25565 on the Colab instance.
server.jar not found error: Ensure you have run the "Download Minecraft server" cell and that server.jar exists in /content/drive/MyDrive/ms/.chmod 600).portmap.io details and ensure the tunnel is active on their side.[SSH] output for any error messages.[MC] output for any error messages. This might indicate issues with Java, server properties, or world data. If a session.lock file exists from a previous improper shutdown, the script attempts to remove it, but manual intervention might be needed for other issues.server.properties file has online-mode=false. While this allows players without a premium Minecraft account to join, it also means usernames are not authenticated, making your server vulnerable to impersonation. For a secure server, set online-mode=true in server.properties (though this would require a premium account for players).This project is open-source and available under the MIT License.