---
name: "connectToServer"
type: command
status: ok
groups: ["System"]
arma3_since: "2.00"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/connectToServer
revid: 373150
updated: 2025-04-04T09:14:53Z
---

# connectToServer

*Command · System · Arma 3 v2.00*

## Description

Connects the client to the provided server.

> [!NOTE]
> - only works on the Main Menu.
> - must be executed from [UI context](../commands/isUIContext.md), such as *onButtonDown* or similar events (see [User Interface Event Handlers](../topics/User_Interface_Event_Handlers.md)).

> [!NOTE]
> **Since Arma 3 v2.20:** If port is 0, the IP will be resolved as a SRV DNS Record.
>
> ["domain.com", 0, "password"] will be resolved as "_arma3._udp.domain.com".
>
> Only the first found record will be used, there is no support for multiple records with priority/weights.

## Syntax

```sqf
connectToServer [ip, port, password]
```

**Parameters:**

- `ip`: [String](../topics/String.md) - IP in <https://en.wikipedia.org/wiki/IPv4> format or Arma 3 v2.20 domain name
- `port`: [Number](../topics/Number.md)
- `password`: [String](../topics/String.md) - "" if no password

**Returns:** [Nothing](../topics/Nothing.md)

## Examples

### Example 1

```sqf
connectToServer ["192.168.0.2", 2302, "test"];
```

### Example 2

```sqf
connectToServer ["publicserver.mydomain.com", 2302, ""];
```

## See also

[serverCommand](../commands/serverCommand.md) · [getSteamFriendsServers](../commands/getSteamFriendsServers.md)

<sub>Source: [BI Community Wiki — connectToServer](https://community.bistudio.com/wiki/connectToServer) (revision 373150).</sub>
