{"name":"connectToServer","title":"connectToServer","type":"command","url":"https://community.bistudio.com/wiki/connectToServer","revid":373150,"updated":"2025-04-04T09:14:53Z","groups":["System"],"status":"ok","games":{"arma3":"2.00"},"since":"arma3 2.00","arma3_since":"2.00","description":"Connects the client to the provided server.\n\n> [!NOTE]\n> - only works on the Main Menu.\n> - must be executed from UI context, such as *onButtonDown* or similar events (see User Interface Event Handlers).\n\n> [!NOTE]\n> **Since Arma 3 v2.20:** If port is 0, the IP will be resolved as a SRV DNS Record.\n>\n> [\"domain.com\", 0, \"password\"] will be resolved as \"_arma3._udp.domain.com\".\n>\n> Only the first found record will be used, there is no support for multiple records with priority/weights.","syntaxes":[{"syntax":"connectToServer [ip, port, password]","params":[{"name":"ip","type":"String","description":"IP in [IPv4](https://en.wikipedia.org/wiki/IPv4) format or Arma 3 v2.20 domain name","type_expr":"String"},{"name":"port","type":"Number","type_expr":"Number"},{"name":"password","type":"String","description":"\"\" if no password","type_expr":"String"}],"returns":{"type":"Nothing","type_expr":"Nothing"},"form":"unary","right":{"text":"[ip, port, password]"}}],"examples":[{"code":["connectToServer [\"192.168.0.2\", 2302, \"test\"];"]},{"code":["connectToServer [\"publicserver.mydomain.com\", 2302, \"\"];"]}],"see_also":["serverCommand","getSteamFriendsServers"]}