# Hytale F2P - Dedicated Server

Host your own Hytale server. The scripts handle everything automatically.

## Prerequisites

- **Java 25+** — [Windows installer](https://download.oracle.com/java/25/latest/jdk-25_windows-x64_bin.exe) | [Other platforms](https://adoptium.net/)
  - If you have the F2P launcher installed, its bundled Java will be used automatically
- **Internet connection** for first launch (downloads ~3.5 GB of game files)
  - If you have the F2P launcher installed, game files are copied locally (no download needed)

## Video Guide

[![Video Guide](https://img.youtube.com/vi/KvuXLH7SKvI/maxresdefault.jpg)](https://youtu.be/KvuXLH7SKvI)

## Quick Start

### Free Hosted Server (no PC required)

Use [play.hosting](https://play.hosting) to get a free Hytale server with F2P support:

1. Register at [play.hosting](https://play.hosting)
2. Create a **Hytale** server
3. Start the server once and wait for it to fully load
4. Go to **Files** → open the `mods` folder
5. Click **New** → **File via URL**
6. Paste: `https://github.com/sanasol/hytale-auth-server/releases/latest/download/dualauth-agent.jar`
7. Click **Query** and download the file
8. Go to **Console** and **Restart** the server

Done — your F2P server is ready to join.

### Windows (self-hosted)

1. Download `start.bat` to an empty folder
2. Double-click `start.bat`
3. Done — server starts on port **5520**

### Linux / macOS (self-hosted)

```bash
mkdir hytale-server && cd hytale-server
curl -O https://git.sanhost.net/sanasol/hytale-f2p/raw/branch/develop/server/start.sh
chmod +x start.sh
./start.sh
```

## What the scripts do

1. Search for the F2P launcher install (default paths + custom `installPath` from config)
2. Use bundled Java from the launcher, or fall back to system Java (25+ required)
3. Copy game files from the launcher install if available
4. Download missing files: `HytaleServer.jar` (~150 MB), `Assets.zip` (~3.3 GB), `dualauth-agent.jar` (~5 MB)
5. Check for updates on every launch (server, assets, and agent)
6. Generate a persistent server ID
7. Fetch authentication tokens
8. Start the server with dual-auth support

## Connecting

- **Same PC**: Connect to `localhost:5520` or `127.0.0.1:5520`
- **LAN**: Connect to your local IP (e.g. `192.168.1.x:5520`)
- **Internet**: Forward port `5520` (TCP + UDP) on your router, friends connect to your public IP

### No public IP? Use playit.gg (recommended)

If you're behind CGNAT or can't port forward, [playit.gg](https://playit.gg) gives you a public address for free:

1. Go to [playit.gg](https://playit.gg) and create an account
2. Download and run the playit agent
3. Create a tunnel — select **Hytale** as the game type, local port `5520`
4. Share the generated address with friends (e.g. `something.joinplayit.gg:12345`)

### Other options

- [Radmin VPN](https://www.radmin-vpn.com/) — virtual LAN, all players must install it
- [ZeroTier](https://www.zerotier.com/) — same idea, create a network, friends join and connect via VPN IP

## Configuration

Set environment variables before running the script:

| Variable | Default | Description |
|----------|---------|-------------|
| `SERVER_NAME` | `My Hytale Server` | Server name shown in listings |
| `BIND_ADDRESS` | `0.0.0.0:5520` | IP and port to listen on |
| `JVM_XMX` | *(Java default)* | Max memory (e.g. `4G`, `8G`) |
| `JVM_XMS` | *(Java default)* | Initial memory |
| `AUTH_MODE` | `authenticated` | Auth mode (`authenticated` or `none`) |
| `HYTALE_AUTH_DOMAIN` | `auth.sanasol.ws` | Auth server domain |
| `DOWNLOAD_BASE` | `https://download.sanasol.ws/download` | File download URL |

**Example (Linux):**
```bash
SERVER_NAME="Epic Server" JVM_XMX=4G ./start.sh
```

**Example (Windows):**
```cmd
set SERVER_NAME=Epic Server
set JVM_XMX=4G
start.bat
```

## Files created

```
your-folder/
├── start.sh / start.bat     # Startup script
├── HytaleServer.jar          # Game server (auto-downloaded)
├── Assets.zip                 # Game assets (auto-downloaded)
├── dualauth-agent.jar         # Auth agent (auto-downloaded)
├── .server-id                 # Persistent server UUID
├── .versions/                 # Version tracking for auto-updates
├── Server/                    # Server data (created by server)
│   ├── config.json
│   └── worlds/
└── UserData/                  # Player saves
```

## Troubleshooting

| Problem | Solution |
|---------|----------|
| `java not found` | Install the F2P launcher (includes Java) or install Java 25+ from [adoptium.net](https://adoptium.net/) |
| Download fails | Check internet connection. Files can be downloaded manually from `https://download.sanasol.ws/download/` |
| Port already in use | Change port: `BIND_ADDRESS=0.0.0.0:5521 ./start.sh` |
| Out of memory | Set more RAM: `JVM_XMX=4G ./start.sh` |
| Friends can't connect | Forward port 5520 (TCP+UDP) on your router, or use [playit.gg](https://playit.gg) if you can't port forward |

## Community

Need help? Join the community: TG Group: https://t.me/sanhostnet | TG Channel: https://t.me/hf2p_og | Chat: https://chat.sanhost.net/invite/Tfz4jCK4
<!-- Discord: https://discord.gg/Fhbb9Yk5WW -->
