Shadowrocket WireGuard Setup: PrivateKey, PublicKey, Endpoint, and Other Fields

Learn how to enter a provider’s WireGuard settings in Add Server. This guide explains PrivateKey, PublicKey, Endpoint, Address, MTU, and other fields using non-working example values.

At a glance

If you have a WireGuard client configuration from your provider, first distinguish your device from the peer: PrivateKey and Address belong to your device, while PublicKey and Endpoint come from the [Peer] you want to connect to. After saving, test connectivity with a request you know will use that connection. Then troubleshoot routing, DNS, or MTU separately to avoid conflating different layers.

Identify your device and the peer in the configuration file

A typical WireGuard client configuration puts your device’s settings in [Interface] and the remote peer’s settings in [Peer]. The snippet below shows only where fields appear. The domain, tunnel address, port, and MTU are illustrative; the key strings are intentionally unusable. Do not paste this into a client as a working configuration.

[Interface]
PrivateKey = DEMO-LOCAL-KEY
Address = 192.0.2.10/32
MTU = 1420

[Peer]
PublicKey = DEMO-PEER-KEY
Endpoint = wg.example.com:51820
AllowedIPs = 192.0.2.0/24
2 sections
Configuration sections: local [Interface] and remote [Peer]
51820
A commonly used UDP port; use the port specified in your provider’s Endpoint
/32
Single IPv4 address with prefix; keep it as shown in the original configuration

If the original file contains multiple [Peer] sections, don’t copy PublicKey from one and Endpoint from another. Use the matching values from the section for the peer you’re adding. If you’re unsure, ask your provider for the parameters for that specific peer.

Check PrivateKey, PublicKey, Endpoint, Address, and MTU

FieldWhat it means and what to enter
PrivateKeyThe device’s private key, used to prove its identity. Enter the value from [Interface]; don’t generate a replacement, since the peer is usually configured with the corresponding public key. Never share your private key in screenshots, support tickets, or chat messages.
PublicKeyThe peer’s public key. Enter the value from the selected [Peer]. It is not the public key derived from your device’s private key; despite having the same format, the two keys are not interchangeable.
EndpointThe host and port that the outer UDP packets are sent to. If the form has separate fields for the address and port, use wg.example.com as the host and 51820 as the port in this example. If an IPv6 host and port go in one field, use brackets, as in [2001:db8::1]:51820.
AddressThe tunnel address assigned to your device by the provider. This is neither the Endpoint host address nor your device’s address on its current Wi-Fi network. Keep the prefix from the configuration, for example 192.0.2.10/32. If the original configuration assigns both IPv4 and IPv6 addresses, make sure you enter both.
MTUThe maximum size, in bytes, of IP packets carried by the tunnel interface. WireGuard encapsulation adds outer overhead, so 1420 is not a universal value. If the original configuration doesn’t specify an MTU, keep the client’s default.

The original configuration may also include PresharedKey, PersistentKeepalive, or AllowedIPs. If the form has corresponding fields, use the values supplied by your provider. PresharedKey is an additional key that both sides must configure; keep it private as well. PersistentKeepalive is measured in seconds and can keep a NAT mapping alive while idle; it is not a handshake timeout. AllowedIPs specifies the destination address ranges handled by the peer and is also used to validate source addresses received from that peer; it is not the same as Shadowrocket routing rules. If the interface lacks a field your provider marks as required, don’t put the value in a different field. Confirm which configuration options that platform supports.

Enter and test the settings in Add Server

  1. Open the add-server screen

    In Home, tap the “+” in the upper-right corner to open Add Server, then select WireGuard under Type. These steps cover manual setup. If you already have an entry under Subscribe, first check whether the subscription already includes the same connection.

  2. Enter your device’s settings

    Use [Interface] to enter the private key and tunnel address. Enter an MTU only if one is specified. When copying a key, copy only the value to the right of the equals sign. Preserve any trailing equals signs in the value, and don’t include the field name, quotation marks, or line breaks.

  3. Enter the peer’s settings

    Copy the peer’s public key, host, and port from the same [Peer] section. Enter any other parameters in their corresponding fields. Don’t prepend https:// to the host or enter a webpage address or subscription URL in Endpoint.

  4. Save and select the entry

    After saving, return to Home, select the entry you just added, and turn on the connection switch. If the system asks to add a VPN configuration for the first time, make sure the prompt was triggered by your action before allowing it. An enabled switch means the local connection is on; it doesn’t confirm that the peer handshake succeeded.

  5. Verify with a real request

    Use a test destination provided by your provider, or choose a known destination that should use this connection and falls within the peer’s configured address ranges. Then make an actual request. If you’re using Config, first check that the destination’s rule points to the entry you selected. Opening a site that matches DIRECT won’t tell you whether WireGuard is working.

Use Global Routing to distinguish routing issues from connection failures

For each test, keep the network and destination the same and change only one setting at a time. Before changing Address or MTU, compare the result of the same request in Config and Proxy. This makes it easier to tell whether the issue is with the rules or the connection itself.

Config

Recommended

Route traffic according to the rules in the current configuration. In Config, check the first rule that matches the destination and its policy; if no earlier rule matches, check the final FINAL rule. Make sure the destination hasn’t been routed to DIRECT or another entry by an earlier rule.

Best for: everyday rule-based routing or checking where a specific destination is routed.

Proxy

Send requests handled by the client through the currently selected proxy entry, without routing them rule by rule according to the configuration. This doesn’t change the address ranges handled by the WireGuard peer. If the request succeeds only in Proxy, check the policies and rule order in Config first. Restore your previous routing mode after testing.

Best for: temporarily comparing the same test request under different routing modes.

Common handshake, DNS, and MTU issues

The switch is on, but there’s still no connection. Why?

Start with a request you know should use this entry. If diagnostics show that the handshake is not completing, check the Endpoint host and UDP port, confirm that the public keys correspond to the correct peers, and make sure you haven’t missed a PresharedKey included in the configuration. If permitted, test the same configuration on another network to see whether the issue is related to UDP connectivity on your current network.

The tunnel can reach an IP address, but not a domain name. What should I check?

Test an IP destination and a domain destination explicitly provided by your provider, then check that the DNS server used by the current configuration is reachable and that the domain isn’t routed under a different policy. If Endpoint is a domain name, make sure it can be resolved before the tunnel is established. Don’t casually replace a domain in a website URL with an IP address for testing; that can also change HTTPS certificate and virtual-host behavior.

Small requests work, but large downloads stall. Why?

On the same network and with the same test destination, check whether the issue reproduces consistently and note the original MTU. Small requests succeeding while large transfers stall is consistent with a path MTU issue, but packet loss or server-side rate limiting could also be responsible. Adjust MTU only if your provider gives you a recommended value or test range, and test that change on its own. If it doesn’t help, restore the original value. Don’t change the port and rules at the same time.

Will updating a subscription also change manually added entries?

Manually added entries and entries managed by Subscribe are maintained separately. If your provider changes its settings, first check which entry is selected in Home. Update subscription entries through the original subscription; edit manually added entries to match the new configuration. After updating, select the correct entry again and retest with the same destination.

Download Shadowrocket for all platforms