# getServerIP (Server)

> Returns the machine's public IPv4 address, read from its network interfaces at start.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Server
- **Category**: Server
- **URL**: https://wiki.mymp.gg/en/getServerIP-server

## Syntax

```lua
string|false getServerIP([bool withPort = false])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `withPort` | `bool` | If `true`, `:port` is appended. *(default: `false`)* |

## Returns

The address, such as `"203.0.113.7"` or `"203.0.113.7:27015"`. `false` if the machine has no public address, as behind NAT or in a container.

## Example

```lua
local address = getServerIP(true)
if address then
    print("connect to " .. address)
end
```

## See also

- [getServerName (Server)](https://wiki.mymp.gg/en/getServerName.md): Returns the server's name, from the server_name convar.
- [getServerIp (Client)](https://wiki.mymp.gg/en/getServerIp-client.md): Returns the address of the server this client is connected to.
