Constant LAN port?

Constant LAN port? - Cables Connected to Ethernet Ports

Occasionally, a friend wants to join me, playing on my Minecraft world, which I run locally on my computer.

We don't want to use VPN or other stuff, so we currently do it using this procedure:

  1. I start Minecraft, load my world, then click "open to LAN". I note the random generated port.
  2. I open my NAT router configuration and forward that port to my computer
  3. I open that port in the Windows Firewall.
  4. I look at myip.is to find out my current public IP, which changes every 24h.
  5. I give my buddy my public IP address, and the port, so he can connect to "[ip-address]:[port]"
  6. After the game session, I will remove the port from the NAT Port forwarding table and in the Windows Firewall (because it will be invalid in the next session)t

I do know that step 4 can be dropped if I use a Dynamic-DNS service. I think I will set one up.

But I find it very annoying to always re-configure my Windows Firewall and the NAT Port Forwarding Table, just because Minecraft always listens to a random port.

What can I do to make the procedure more easy? Can't I simply tell Minecraft to always use the same port when playing "local" in LAN (actually WAN, because I use port-forwarding).



Best Answer

According to Minecraft's Wiki, you can use the /publish command.

/publish [port]

port: integer

    Must be a 32-bit integer number. And it must be between 0 and 65535 (inclusive).
    The port to host on. If not specified, a random port above 1024 is chosen.



Pictures about "Constant LAN port?"

Constant LAN port? - Close Up Photo of Cables Plugged into the Server
Constant LAN port? - Cables Connected on Server
Constant LAN port? - Ethernet Cables Plugged in Network Switch



How do I make Minecraft use the same port?

UPDATE: You cannot change the port in the GUI. Turns out there is a commandline (only) option that allows you to set fix the port number. https://minecraft.gamepedia.com/Commands/publish . This allows you to fix the port number for your "Open to Lan" game.

How do I find my Minecraft LAN port?

If you hit / inside the world just after you open it to LAN, it will show you what port it opened on.

How do I change my Minecraft to LAN?

Playing on a Local Area Network (LAN)
  • Choose a host computer. ...
  • Launch the game and click Single Player.
  • Create a new world or open an existing one.
  • Inside that world, press the Esc key, and click Open to LAN.
  • Choose a game mode to set for the other players.


  • How do I change my Minecraft client port?

    How to Change the MC Port
  • Open a web browser and connect to MC as a user with MC ADMIN privileges.
  • On the MC Home page, navigate to MC Settings > Configuration and change the Application server running port value from 5450 to a new value.
  • In the change-port dialog, click OK.
  • Restart MC.




  • Network Ports Explained




    More answers regarding constant LAN port?

    Answer 2

    No, LAN worlds always use random ports. You would need to run a dedicated server to choose your port. You can move the world folder to the server and either rename it to "world" or change server.properties to use its name.

    Answer 3

    Press the windows key + R on Windows 10, windows key + X on Windows 8, or select Start > Run on other windows PCs.

    Then type %appdata%\.minecraft open the folder called something like, "worlds" and select the world name you want in the server. Then press ctrl+C to copy it.

    Go to your server folder, and delete the old world. Paste the new world in, and rename it "world".

    Answer 4

    The Open to Lan on a Minecraft client always be used a random port, you cannot change that.

    UPDATE: You cannot change the port in the GUI. Turns out there is a commandline (only) option that allows you to set fix the port number. https://minecraft.gamepedia.com/Commands/publish . This allows you to fix the port number for your "Open to Lan" game. Because in most of these scenarios the IP address will still be randomly selected the experimental tool below may still prove useful.


    However this open-to-lan server then starts announcing on the network where this Minecraft server can be found.

    I recently created a PoC that listens for those announcements and sets up a proxy that makes this server available on a fixed port.

    This PoC is quick and dirty (requires Linux) and intends just to show this is a possibility.

    In case you want to see it I put it on github https://github.com/nielsbasjes/minecraft-open-to-lan

    Answer 5

    There's a forge mod to configure lan servers and I'm pretty sure it works with vanilla clients, so your friend won't need it.

    It allows you to configure which port the server runs on, so that should solve your problem.

    Link: Custom Lan Mod

    Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

    Images: Brett Sayles, Brett Sayles, Brett Sayles, Brett Sayles