> For the complete documentation index, see [llms.txt](https://docs.fivemstats.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fivemstats.net/tgiann-fivem-stats-script/ports-and-firewall.md).

# Ports and Firewall

The ports FiveM Stats, players and browsers connect to, and how to open them.

The script never changes your firewall. Open the ports below yourself, in the system firewall and in your host's panel.

{% hint style="info" %}
Serving media through your own proxy or a [Cloudflare Tunnel](https://docs.fivemstats.net/tgiann-fivem-stats-script/https/cloudflare-tunnel.md) with `tgiann_media_host "127.0.0.1"`? Then the media port and `80` stay closed; only the proxy's own port is open. See [HTTPS](https://docs.fivemstats.net/tgiann-fivem-stats-script/https.md).
{% endhint %}

## Ports

| Port                                                | Protocol    | Who connects                                              | What for                                                                                                                                                                                                                                       |
| --------------------------------------------------- | ----------- | --------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Game port (`endpoint_add_tcp`, `30120` by default)  | TCP and UDP | Players, FiveM Stats                                      | Joining the server. The panel's statistics API at `/tgiann-fivem-stats-script/`                                                                                                                                                                |
| Media port (`tgiann_media_port`, `6174` by default) | TCP         | Players' games, browsers with the panel open, FiveM Stats | Screenshot uploads, pictures and videos in the panel and in game, uploads and ZIP downloads from the [Media](https://docs.fivemstats.net/panel/media.md) page, downloads from the [Backups](https://docs.fivemstats.net/panel/backups.md) page |
| `80`                                                | TCP         | Let's Encrypt                                             | Only when `tgiann_media_https` is `auto` (the default), and only while a certificate is checked, about every 4 days                                                                                                                            |

{% hint style="warning" %}
Port 80 must be free. If another program listens on it (IIS, nginx, Apache, XAMPP), the certificate cannot be issued. Use `custom` or `off` instead, see [HTTPS](https://docs.fivemstats.net/tgiann-fivem-stats-script/https.md).
{% endhint %}

## Windows

Open PowerShell as administrator:

```powershell
New-NetFirewallRule -DisplayName "FiveM Stats media" -Direction Inbound -Protocol TCP -LocalPort 6174 -Action Allow
New-NetFirewallRule -DisplayName "FiveM Stats HTTPS check" -Direction Inbound -Protocol TCP -LocalPort 80 -Action Allow
```

## Linux

With ufw:

```bash
sudo ufw allow 6174/tcp
sudo ufw allow 80/tcp
```

## Your host's firewall

Many VPS and dedicated server hosts have a second firewall or a DDoS filter in their control panel. Open the same ports there too, otherwise the rules above have no effect. Hosts with a FiveM DDoS profile on the game port also need a change there: [DDoS-Protected Hosts](https://docs.fivemstats.net/tgiann-fivem-stats-script/ports-and-firewall/ddos-protected-hosts.md).

## Changing the media port

If another program already uses `6174`, pick another free port. Set it before the script starts and restart the server:

```cfg
set tgiann_media_port 6175
ensure tgiann-fivem-stats-script
```

{% hint style="warning" %}
Pick the port once. Links other scripts already saved (a phone gallery, an MDT report) contain the port and stop working when it changes.
{% endhint %}

## Check from outside

From another network (a phone on mobile data is enough) open:

```txt
http://<server-ip>:6174/health
```

A working service answers with `"status":"ok"`, its public address and the HTTPS state. No answer means the media port is still closed somewhere.
