Running your own XMage server lets you play against AI opponents without relying on a public instance, host private matches with friends, or operate a public server for the wider community. The server is a headless Java process configured entirely through a single XML file. This guide walks through initial setup, every configuration option, firewall requirements, and optional features like user authentication and email verification.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/magefree/mage/llms.txt
Use this file to discover all available pages before exploring further.
How the Server Finds Its Config File
The server reads its configuration fromconfig/config.xml relative to its working directory by default. This path is defined in Main.java:
Quick-Start Steps
Install Java
Ensure Java 8 or later is installed on the machine that will run the server. See System Requirements for platform-specific notes.
Extract XMage
Unpack the XMage archive from http://xmage.today/ to a folder the server process can write to.
Edit config.xml
Open
config/config.xml and set serverAddress to your machine’s IP address or domain name (use 0.0.0.0 to bind to all interfaces). Update port and secondaryBindPort if the defaults conflict with other services.Open Firewall Ports
Allow inbound TCP traffic on both configured ports (default
17171 and 17179) from the firewall on the server machine and, for public servers, from your router/NAT device as well.Start the Server
Use the XMage Launcher (Start Server button) or run the server JAR directly:The log will confirm the listening address:
Connect a Client
From the XMage client connection dialog, enter your server’s IP or hostname and port
17171. See Client Setup for client installation instructions.Complete config.xml <server> Reference
Below is the full default <server> element extracted from Mage.Server/config/config.xml, followed by a detailed description of every attribute.
Network Settings
| Attribute | Default | Description |
|---|---|---|
serverAddress | 0.0.0.0 | IP address or domain the server binds to. Use 0.0.0.0 to listen on all interfaces. For public servers, set this to the public IP or domain that clients can reach (e.g. xmage.mydomain.com). |
serverName | mage-server | Display name shown to connecting clients. |
port | 17171 | Primary TCP port for client connections. |
secondaryBindPort | 17179 | Secondary (callback) port. Set to -1 to let the OS choose an ephemeral port — avoid -1 behind NAT. |
backlogSize | 200 | Maximum number of pending (unaccepted) incoming connections. Further requests are rejected when the queue is full. JBoss default is 200. |
numAcceptThreads | 2 | Number of threads listening on the primary ServerSocket. JBoss default is 1; 2 is a reasonable starting value. |
maxPoolSize | 300 | Maximum number of active server worker threads at any given time. JBoss default is 300. |
leasePeriod | 5000 | Interval in milliseconds at which the server sends lease pings to detect dead clients. A value greater than 0 enables server-side connection failure detection. |
socketWriteTimeout | 10000 | Timeout in milliseconds for socket write operations. Writes that do not complete within this window are aborted. |
maxPoolSize sizing for active public servers: each connected client can consume multiple worker threads simultaneously (one per in-flight request). As a rule of thumb, set maxPoolSize to approximately max_concurrent_users × 20. For example, a server expecting up to 50 simultaneous users should use maxPoolSize="1000". If maxPoolSize is reached, new clients will stall in the connection dialog until a thread becomes free or the backlog overflows.Game Settings
| Attribute | Default | Description |
|---|---|---|
maxGameThreads | 10 | Maximum number of games that can run simultaneously on the server. Each game occupies one thread. |
maxSecondsIdle | 300 | Seconds of player inactivity before the server auto-concedes the idle player’s game. |
maxAiOpponents | 15 | Maximum number of AI (computer) opponents that can be active across all games at once. Draft bots are unlimited and not counted here. |
saveGameActivated | false | Enable game save and replay functionality. Note: this feature is not fully stable yet. |
User Name & Password Constraints
| Attribute | Default | Description |
|---|---|---|
minUserNameLength | 3 | Minimum character length for a valid username. |
maxUserNameLength | 14 | Maximum character length for a valid username. |
invalidUserNamePattern | [^a-z0-9_] | Java regex pattern matching invalid characters in a username. The default allows only lowercase letters, digits, and underscores. |
minPasswordLength | 8 | Minimum password length when authentication is enabled. |
maxPasswordLength | 100 | Maximum password length when authentication is enabled. |
Authentication
| Attribute | Default | Description |
|---|---|---|
authenticationActivated | false | When false, anyone can connect with any username without registering. Set to true to require users to register an account (and verify via email if mail is configured). |
authenticationActivated is true, a mail backend must be configured so that the server can send account-verification emails. XMage supports two backends:
Option A — Mailgun (recommended for public servers)
Leave mailUser empty and supply your Mailgun credentials:
The server chooses between Mailgun and SMTP by checking whether
mailUser is empty. If mailUser is blank, Mailgun is used; otherwise, the SMTP settings take precedence.Example: Minimal Public Server Config
The snippet below shows a production-ready configuration for a small public server expecting up to 20 simultaneous users, with authentication enabled via Mailgun:203.0.113.42 with your server’s actual public IP or hostname.
NAT and Port Forwarding
For clients on the internet to reach a server behind a home router:- Assign a static local IP to the server machine (or use a DHCP reservation).
- In your router’s port-forwarding settings, forward external TCP
17171→ server local IP17171, and TCP17179→ server local IP17179. - Set
serverAddressinconfig.xmlto your public IP or dynamic-DNS hostname (e.g.myhome.ddns.net), not0.0.0.0— clients need to be told the address they connect back to.
Test Mode
For development and testing, start the server with thexmage.testMode JVM property:
-Dxmage.testMode=true to Settings → Java → Server java options in the launcher.
Test mode enables:
- Fast-game buttons and cheat commands in the client
- No deck validation
- Simplified registration and login (no password check)
- No draft click-protection timeouts
- No disconnection on IDE debugger pauses (pings disabled)
- Debug main menu in the client when launched with
-debug
