How to set up a Hysteria2 server on a VPS

Hysteria2 is a QUIC-based protocol that keeps its speed on lossy networks. The server installs with the official script in a couple of minutes; after that it is one config file, a password, a certificate and an open UDP port. The Veli app doesn't install Hysteria2 on your own server — it only connects to one — so below is the manual install.

Updated

On this page

What you need

  • A VPS with Linux and systemd — Ubuntu or Debian, say — and root access over SSH.
  • A free UDP port. Most people take 443: QUIC on it looks like the HTTP/3 of an ordinary website.
  • A TLS certificate. A real one is better — for that you need a domain pointing at the server's IP. Without a domain a self-signed one will do, but then the client has to skip certificate checks or pin the certificate's fingerprint.
  • A network that lets UDP through. If UDP is cut or throttled there, Hysteria2 won't help — you need a TCP protocol such as VLESS Reality.

Installation

  1. 1

    Run the official script

    As root, run:

    On the server
    bash <(curl -fsSL https://get.hy2.sh/)

    The script puts the program in /usr/local/bin/hysteria and creates the hysteria-server systemd service. Running the same script again updates Hysteria2.

  2. 2

    Write the config file

    The settings live in /etc/hysteria/config.yaml. What goes in it is in the next section. The file is YAML: indentation matters, and tabs are not allowed.

  3. 3

    Start the service

    On the server
    systemctl enable --now hysteria-server.service

    The service starts now and after every reboot. systemctl status hysteria-server.service shows its state, journalctl -u hysteria-server.service its log.

  4. 4

    Open the UDP port

    If ufw is on: ufw allow 443/udp. If your host has a firewall in its control panel, open the port there too — over UDP, not TCP.

  5. 5

    Build the link

    The address, port and password make a hysteria2:// link — paste it into a client or show it as a QR code. The format is in the last section.

What goes in config.yaml

  • listen: :443 — the port the server waits on. It is a UDP port.
  • acme — the block for a real certificate: your domain under domains, your email under email. Hysteria2 obtains the certificate and renews it by itself; the domain must point at the server, and TCP port 80 or 443 must be free for the check.
  • tls — instead of acme, for your own or a self-signed certificate: the certificate file's path under cert, the key's under key. The service doesn't run as root but as its own hysteria user, so the files must be readable by it.
  • auth — how clients log in: type: password, with a long random password under password. It goes into the link too, so letters and digits are the easiest choice.
  • masquerade — what someone who opens the server without the password sees: type: proxy, with a real website's url under proxy and rewriteHost: true. Then from outside the server answers like an ordinary website over HTTP/3.
  • bandwidth — optional. Without it Hysteria2 manages its speed with the BBR algorithm. Set the line's speed and it holds that speed even under loss — set it honestly, at your real speed, or it will flood the line.
  • A self-signed certificate is made with openssl req -x509 -nodes -newkey rsa:2048 -days 3650 -keyout /etc/hysteria/server.key -out /etc/hysteria/server.crt -subj /CN=example.com, and the service gets access with chown hysteria /etc/hysteria/server.key /etc/hysteria/server.crt.

The hysteria2:// link

The format is: hysteria2://password@address:port/?sni=domain#name. The password comes before the @; special characters in it are encoded as in web addresses. Clients also understand the short hy2:// instead of hysteria2://. After the # comes the name the client shows in its list.

Example
hysteria2://Kd83hQx2Vb7mZp@vpn.example.com:443/?sni=vpn.example.com#my-hy2

With a real certificate, sni is the domain it was issued for. With a self-signed one, add insecure=1 — the client won't check the certificate. Pinning its fingerprint with pinSHA256 — the certificate's SHA-256 — is safer: then nobody on the way can swap the server.

Need several users? auth has other login types, such as userpass with a list of names and passwords. Then the link has the name and password separated by a colon before the @. For one or two devices of your own, a single password is enough.

In Veli

The app connects the link

Veli doesn't install Hysteria2 on your own server — you set the server up by hand, as above. It connects like any link: Profiles → Add, paste the hysteria2:// link and press the button under the field — the app works out that it is Hysteria2. The profile becomes a row in Profiles; click “Connect”. If the sing-box or Xray module isn't there yet, the app offers to install it.

On Android it is the same: Profiles → Add, paste the link and tap “Continue” — or “Scan a QR code”. Per-app rules and site lists work on Hysteria2 on both a computer and a phone. Don't turn on TLS fragmentation for Hysteria2: it breaks its handshake. Want a protocol the app installs by itself? “Your own server” installs VLESS Reality, AmneziaWG, WireGuard, Shadowsocks and OpenVPN.

FAQ

Does Veli install Hysteria2 on my own server?

No. A Hysteria2 server is set up by hand, and Veli connects to it with a hysteria2:// link. On your own server the app itself installs VLESS Reality, AmneziaWG, WireGuard, Shadowsocks and OpenVPN.

Which port does Hysteria2 need?

Any free UDP port, most often 443. Open it over UDP specifically — both in the server's firewall and in your host's control-panel firewall, if it has one.

Can I set up Hysteria2 without a domain?

Yes, with a self-signed certificate. Then the link needs insecure=1 or, safer, pinSHA256 with the certificate's fingerprint.

Connect your Hysteria2 server in a minute

Paste the hysteria2:// link into Veli — the server goes into Profiles, and the kill switch is one switch in Settings → Security.