Search code examples
minecraftminecraft-fabricgithub-codespaces

Is it possible to host a Minecraft server on GitHub Codespaces?


I downloaded the Fabric server jar file to a GitHub Codespace and am able to run the server without trouble. However, I am unable to determine the IP needed to connect to the server. Starting the server automatically forwards port 25565 and I make the port public. However, I can't figure out which IP to paste into Minecraft to connect to it. How do I figure out the IP of the server?


Solution

  • I found an answer thanks to inspiration from this question.

    Steps:

    1. Set up the fabric server jar as you normally would, but on the codespace. Start the server.
    2. Split the terminal so one is running Java (server console) and the other is running bash.
    3. Install ngrok via npm i ngrok --save-dev.
    4. Once the server is finished setting up, run the command ./node_modules/.bin/ngrok tcp 25565.
    5. Copy the ip shown under Forwarding (minus the tcp:// part and including the port). This should look something like 4.tcp.ngrok.io:17063.

    You now have the ip of the server!

    Note: The free version of ngrok has URLs which change every time, as well as a limit, but for small-scale servers this shouldn't be an issue. You are also limited by the free codespace usage limit GitHub puts in place. (Edit: found out this is against their ToS; you can only have one free account) However, you can easily get around this by creating a secondary account that you use codespaces on only for the server.