Query number of players on a minecraft server
Without the minecraft client, there is a scripted (php, python, whatever) way to ask basic information (what you see in the multiplayer menu) to a minecraft server.
Does anyone knows the few magical bytes to send on the port 25565 ?
Best Answer
(Not an answer as it expands on Nope's, but too long for a comment, and I need code formatting)
Nope's code breaks for me (MC 1.10) as popint doesn't seem to decode multi-byte integers correctly; bytes are received in little endian order (lowest byte first). If a server has a large icon, the length doesn't get decoded correctly, which, in some cases, works anyway (as the code always reads 1024 bytes even when l is smaller), in others, you get an error from the JSON decoder about an unterminated string.
Replacing the popint function with this fixes the issue:
def popint(s):
acc = 0
shift=0
b = ord(s.recv(1))
while b & 0x80:
acc = acc | ((b&0x7f)<<shift)
shift = shift + 7
b = ord(s.recv(1))
return (acc)|(b<<shift)
Pictures about "Query number of players on a minecraft server"



How do you check how many people are on a Minecraft server?
Press TAB , then you will see who is online on the server. To change the button binding for this, press ESC and go to Controls. True.How do you list all players in Minecraft?
How to Enter the CommandHow many players can a Minecraft server hold?
You CAN SET the Slots to 2147483647, yes. BUT you have to connect to the Server and since there are Ports from 0 to 65535 there Could be 65535 Clients, then all incoming ports are full.How do I check my minecraft server stats?
How to View your Statistics. Statistics are found under the Game Menu in Minecraft. To open the Game Menu, press the esc key in Minecraft Java Edition (PC/Mac). Then view your statistics by clicking on the Statistics button in the Game Menu.How To Get Players on Your Minecraft Server
More answers regarding query number of players on a minecraft server
Answer 2
Yes, there is now a quasi-official Python class to do this; it’s written by this guy.
It can be called directly from the command line (or can be used as a Python library).
To check if your server is up, get player count, etc., is as simple as:
mcstatus minecraft.example.com query
…and the exit code will be set, so you can even integrate this into e.g. automated heartbeat systems for checking uptime.
(You can use ping instead of query to test latency, at the cost of it taking a bit longer to run.)
It, unlike the currently-accepted answer:
- supports
SRV-masked Minecraft servers (e.g. multiple servers on one IP) - will stay up-to-date when Minecraft's handshake protocol next evolves
- it supports Bedrock Edition servers, too!
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Joe Calomeni, Dmitry Egorov, Inderjeet Kashyap, Ron Lach
