> ## Documentation Index
> Fetch the complete documentation index at: https://docs.socketchat.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Host on a cloud server

> Run an always-on Socketchat server on a small Linux VPS with your own domain name.

> [!NOTE]
>
> New to this? Read [How Socketchat works](/how-it-works) first.

A VPS (virtual private server) is a small Linux machine you rent from a cloud provider by the month. It stays on, has its own public IP address, and keeps your home address out of the picture. The smallest plan most providers offer is enough to start.

You need:

* a Linux VPS from any provider, such as [Hetzner](https://www.hetzner.com/cloud) or [DigitalOcean](https://www.digitalocean.com). Pick Ubuntu 22.04 or newer, or Debian 12 or newer;
* a domain name you control, such as `example.com`;
* SSH access to the VPS.

## Set it up

**1. Point a name at the server**

In your domain's DNS settings, add an **A record**: a DNS entry that points a name at an IPv4 address.

| Type | Name | Value |
| - | - | - |
| A | `chat` | your VPS's public IPv4 address |

That makes `chat.example.com` reach the VPS. Changes can take a few minutes to spread. Check with `ping chat.example.com` from your own computer.

**2. Open port 7444**

Allow incoming TCP on port 7444 in two places:

* **On the VPS**, if it runs `ufw`:

  ```bash theme={"dark"}
  sudo ufw allow 7444/tcp
  ```

  If you turn `ufw` on for the first time, allow SSH first with `sudo ufw allow OpenSSH`, or you lock yourself out.
* **In the provider's firewall**, often called a cloud firewall or security group, if your VPS has one. Add an inbound rule for TCP port 7444.

**3. Install Socketchat**

On the VPS:

```bash theme={"dark"}
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/sachio222/socketchat_v4/releases/latest/download/socketchat-installer.sh | sh
```

The installer puts the program in `~/.local/bin/socketchat`.

**4. Make a user and a data folder for the server**

Run the server as its own user, with its data in `/var/lib/socketchat`:

```bash theme={"dark"}
sudo useradd --system --home-dir /var/lib/socketchat --shell /usr/sbin/nologin socketchat
sudo install -d -o socketchat -g socketchat -m 700 /var/lib/socketchat
sudo install -m 755 ~/.local/bin/socketchat /usr/local/bin/socketchat
```

**5. Set up the server with your domain name**

```bash theme={"dark"}
sudo -u socketchat socketchat server init --data-dir /var/lib/socketchat --host chat.example.com
```

`init` writes `socketchat-server.toml`, makes the certificate and prints its fingerprint.

## Run it as a service

systemd is the program that starts and watches services on most Linux systems. This unit comes from the project's server guide. Save it as `/etc/systemd/system/socketchat.service`:

```ini /etc/systemd/system/socketchat.service theme={"dark"}
[Unit]
Description=socketchat server
After=network-online.target
Wants=network-online.target

[Service]
User=socketchat
Group=socketchat
ExecStart=/usr/local/bin/socketchat server run --data-dir /var/lib/socketchat
Restart=on-failure
KillSignal=SIGINT
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
PrivateTmp=true
ReadWritePaths=/var/lib/socketchat

[Install]
WantedBy=multi-user.target
```

`KillSignal=SIGINT` sends the same signal as Ctrl-C, which the server handles by closing connections and stopping cleanly. Start it, then make your own invite:

```bash theme={"dark"}
sudo systemctl daemon-reload
sudo systemctl enable --now socketchat
sudo -u socketchat socketchat server invite --data-dir /var/lib/socketchat
```

Join with that link from your own computer, as in the [Quick start](/quickstart). `journalctl -u socketchat` shows the address and certificate fingerprint the server printed at start.

## Update the server

**1. Get the new release**

Run the installer again on the VPS. It replaces `~/.local/bin/socketchat` with the newest release.

**2. Back up the data folder**

See [Back up](/hosting/server-settings#back-up).

**3. Swap the program and restart**

```bash theme={"dark"}
sudo systemctl stop socketchat
sudo install -m 755 ~/.local/bin/socketchat /usr/local/bin/socketchat
sudo systemctl start socketchat
```

Servers and apps from different releases work together, so you can update the server before or after your members. A feature that needs a newer server says so in the app and leaves the rest working.

## Next

[Server settings and backups](/hosting/server-settings) covers the config file, limits, cleanup of old data and backups.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.