Minecraft server owners and developers often need a simple way to check whether a server is online and view important details like player count, server version, and latency. Instead of manually opening Minecraft, you can create a lightweight Minecraft Server Ping Tool using Node.js.
In this tutorial, we will build a command-line tool that connects to a Minecraft APK Android server and displays its current status.
Requirements
Before starting, make sure you have:
- Node.js installed
- npm available
- Basic JavaScript knowledge
Install Dependencies
Create a new project and install the required package:
mkdir minecraft-server-ping
cd minecraft-server-ping
npm init -y
npm install minecraft-server-util
Create the Ping Tool
Create a file named index.js and add the following code:
const { status } = require("minecraft-server-util");
const HOST = "play.hypixel.net";
const PORT = 25565;
async function pingServer() {
try {
const result = await status(HOST, PORT);
console.log("Minecraft Server Status");
console.log("----------------------");
console.log("Server:", HOST);
console.log("Version:", result.version.name);
console.log("Players:", `${result.players.online}/${result.players.max}`);
console.log("Ping:", result.roundTripLatency + " ms");
console.log("MOTD:", result.motd.clean);
} catch (error) {
console.log("Unable to connect to the server.");
}
}
pingServer();
Run the Tool
Start the application with:
node index.js
Example output:
Minecraft Server Status
----------------------
Server: play.hypixel.net
Version: 1.21
Players: 50000/200000
Ping: 80 ms
MOTD: Hypixel Network
How It Works
The minecraft-server-util package sends a status request to the Minecraft server and returns useful information, including:
- Minecraft version
- Current online players
- Maximum player limit
- Server MOTD
- Network latency
This tool can be improved by adding features like server monitoring, a web dashboard, uptime tracking, or Discord notifications.
Conclusion
Building a Minecraft Server Ping Tool with Node.js is a great beginner project for learning APIs and server communication. With a small amount of code, you can create a useful utility that checks Minecraft server status and provides real-time information. It can also serve as a foundation for creating more advanced Minecraft management tools.
Top comments (0)