My 5 year old son is really in to playing Minecraft at the moment and always wants me to play with him.  I set up a couple of Minecraft servers on a Linux machine on my local network so that any of us could hop in and out from any computer.  Annoyingly I found that the server for Linux does not broadcast its whereabouts to the LAN, so I had to manually enter the address and ports of the servers on every client.

Well that seemed unnecessary so I opened up Wireshark to see how the Windows and Mac clients announce their LAN games and came up with the following script.  I decided to use Python simply because it was pre-installed on my Linux box and I didn’t want to install another language such as PHP just to handle this simple job.  That said, I don’t know Python very well.

I run this script in a screen session on the Linux server.  It announces the Minecraft servers to the LAN every 1.5 seconds using a UDP broadcast to the subnet.  The clients always assume that the source IP of the broadcast is also the IP address of the Minecraft server, so this script must be run on the same box that is hosting the Minecraft servers.  In other words, you can’t use this script to announce the whereabouts of a Minecraft server on a different machine.  I believe that’s a protocol change to previous versions where this was indeed possible.  At the time of writing, the current Minecraft version is 1.8.

You can add as many servers are you like to the servers array.  The array contains arrays consisting of the server description and the port number.

import socket
import time

servers = [
        ["Local Network - Survival Map", 25565],
        ["Local Network - Creative Playground", 25566]


sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)

print "Broadcasting Minecraft servers to LAN"

while 1:
        for server in servers:
                msg = "[MOTD]%s[/MOTD][AD]%d[/AD]" % (server[0], server[1])
                sock.sendto(msg, (BROADCAST_IP, BROADCAST_PORT))


I was looking back through some of my old stuff and realised that the broadcast address I use above is not always technically correct. In most cases you can probably leave it at so I definitely encourage you to give that a go first. I think the only reason it may fail is if your computer belongs to more than one subnet.

If your servers aren’t showing up then first check the obvious thing – firewalls! Failing that, try using the calculator below to find the specific broadcast address for your subnet and use that instead.

It’s now June 2020 and I’ve tested the above script with the address and it still works so there doesn’t seem to have been a change in the protocol.

Last modified: January 10, 2021



Thanks for sharing, I’m in the same boat. Next minecraft LAN party I won’t have to add the servers to each of the kids computers!

Cheers for this. I had wondered but never went beyond that.

The client can not connect to the server, because the server does not have the IP, shows only port. How to fix it, so that you can specify the IP address of the server?
Screenshot 1:
Screenshot 2:

This worked great for version 1.12, but it no longer seems to work after updating to 1.12.1 🙁

I used wireshark to inspect a packet when I hosted a game on my Mac, and the broadcast had the destination IP address of — so I updated the script to use that. At first nothing changed, but after I restarted Minecraft stuff started showing up. Not sure if it’s a red herring or not.

    You’re right about the broadcast destination IP. It’s an unassigned address in the IANA multicast addresses AD-HOC Block I (RFC5771). I was just looking into this, as I want my dedicated server showing up in the LAN so that my kids can join it even if the DHCP assigned IP of my machine changes. Planning on writing some sort of a wrapper for launching the server, so that as long as the server is alive, it advertises the server on the LAN.


      You’re both right. The broadcast address I use there isn’t the real broadcast address for your networks. I’ve just updated the post with a calculator that can be used to find the correct broadcast address if you want to try that instead. is a special address that should work but if it doesn’t then try using the calculator to see if you get better results. Better 6 years late than never.

Limestone Dad 

Thank you for posting this (back when). I’ve written it as a MinecraftForge plugin (v0.1) and will be hopefully publishing this weekend. As a plugin you dont even need to edit a file for each server, just dump the jar in your mod folder for your server config. (url to follow when posted)

My next steps will be to extend the communication to support the richer message telling the server’s mods, players etc…

Limestone Dad 

A minecraft forge plugin java file is available now. It’s way bigger than the tight python script above, but fits the Forge plugin architecture.


Is this still working?

Based on the above, I updated for Python3 (Linux) for local Minecraft server pair I’m running for my kids:

Not a python coder at the best of times, so there’s probably still a little bit of kludging that could be cleaned up!

Changes to original:
1. Use Python3 compatible code
2. Utilise multicast (because my corporate networking background says “unnecessary broadcast is bad ‘mkay?” 😉)

#2 was the trickiest -I found code for the specific multicast bit easily enough, but I didn’t realise I had to subscribe to the multicast group BEFORE I could send anything to it!


import socket
import time
import struct

# Put your server list here – MOTD then port
servers = [
[‘LAN – World1’, 25565],
[‘LAN – World2’, 25564]

# This is the minecraft default multicast settings – should not need to change

# initialise the multicasting system
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, MCAST_TTL)

# need to subscribe to the multicast group for the sending to work
sock.bind((”, MCAST_PORT))
mreq = struct.pack(“4sl”, socket.inet_aton(MCAST_GRP), socket.INADDR_ANY)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)

print (“Broadcasting Minecraft servers to LAN”)

while True:
for server in servers:
msg = “[MOTD]%s[/MOTD][AD]%d[/AD]” % (server[0], server[1])
sock.sendto(bytearray(msg.encode()), (MCAST_GRP, MCAST_PORT))

Just in case someone is wondering, it’s still working on minecraft 1.18.1

Thanks a lot for the neat script!


this is a nodejs version of this (for the nodejs lovers)

servers = [
[“Local Network – Survival Map”, 25565],
[“Local Network – Creative Playground”, 25566]

require(‘dgram’).createSocket(“udp4”).bind(function () {
this.setBroadcast(true), setInterval(() => servers.forEach((e) => this.send(Buffer.from(`[MOTD]${e[0]}[/MOTD][AD]${e[1]}[/AD]`), 0, Buffer.from(`[MOTD]${e[0]}[/MOTD][AD]${e[1]}[/AD]`).length, 4445, “”)), 1500);

Write a Reply or Comment

Your email address will not be published.