Shadowrocket WireGuard Settings: PrivateKey, PublicKey, Endpoint, and MTU

Learn what each WireGuard field in Shadowrocket means and where to get it. See how to check Address, DNS, and MTU when misconfigured.

At a glance

This guide is for users who already have WireGuard connection details and want to enter or check them in Shadowrocket. First distinguish the client PrivateKey from the server PublicKey, then check the Endpoint, tunnel Address, and DNS. Finally, compare routing settings and test MTU one variable at a time. Get subscription links and connection details from your provider. Don't mix fields from different devices or Peers.

Where WireGuard settings come from and how to enter them

A WireGuard connection in Shadowrocket requires a matching set of settings—not just an address and port. In a typical configuration, [Interface] describes the local identity and tunnel address, while [Peer] describes the remote identity and connection destination. When you see both sections, first identify which side each field belongs to, then match it to the corresponding Shadowrocket field.

This guide assumes you already have a provider and subscription. Subscribe refreshes content published by your provider; it does not fix incorrect keys. Whether a regular subscription includes WireGuard entries depends on the formats your provider supports. Before editing an entry generated by a subscription, check whether a later refresh will overwrite your changes.

  1. Check the source

    Get the WireGuard settings for the same connection from your provider, and distinguish [Interface] from [Peer]. Note whether the configuration includes PresharedKey, an IPv6 Address, and a specified DNS server. Don't share the complete configuration.

  2. Choose the type

    Go to Home → tap “+” in the upper-right corner → Type → WireGuard. To edit an existing entry, open it from Home to avoid changing a different connection that's currently in use.

  3. Enter the identity settings

    Start with the client PrivateKey and Address, then the server PublicKey. If the original configuration includes a PresharedKey, enter that exact key too; don't use the PublicKey in its place.

  4. Enter the destination settings

    Check the server address and port against the Endpoint, then enter the DNS and MTU specified by your provider. If the editor has separate fields for address and port, enter them separately.

  5. Test it separately

    After saving, select the entry on Home and temporarily use Global Routing → Proxy to test a real web request. To avoid interference from automatic connection conditions, turn off Settings → On Demand during the test. Restore your original settings afterward.

PrivateKey and PublicKey: Identify the client and server keys

PrivateKey is the secret part of the local identity; PublicKey is the public part that can be registered with the peer. The client PublicKey can be derived from its PrivateKey, but the PrivateKey cannot be recovered from a PublicKey. In a Shadowrocket connection entry, the remote PublicKey should be the server's—not the key derived from the client PrivateKey.

Field and ownerWhat to enterCommon mistake
[Interface] PrivateKeyThe private key assigned to this clientEntering the server's public key or copying extra spaces
[Peer] PublicKeyThe remote server's public keyEntering the client's own public key
[Peer] PresharedKeyAn additional shared preshared key, required only if the original configuration specifies oneConfigured on one side but left blank on the other, or using a different key by mistake

WireGuard PrivateKey and PublicKey values are Base64 representations of 32-byte raw keys. They are typically 44 characters long and end in =. Length can reveal obvious truncation, but it doesn't prove a key is correct. Preserve uppercase and lowercase letters, +, /, and = when copying. Don't include the PrivateKey = part of the configuration line in the key field.

Changing the private key requires updating the peer too

Generating a new PrivateKey on this device also changes the client PublicKey. If the server still has the old public key registered, the new identity won't authenticate. To change keys, follow your provider's device reset process and make sure the registration is updated. Don't keep generating keys to troubleshoot. Treat PrivateKey, PresharedKey, and complete subscription links as sensitive information.

Endpoint and Address: The public endpoint isn't the tunnel address

Endpoint is the remote UDP address the client contacts first, including a host and port. Address is the internal address used by the client inside the tunnel, usually with a CIDR prefix. They serve different purposes: don't enter the server's domain in Address or use the client's tunnel IP as the public Endpoint.

32 bytes
Raw key length for each PrivateKey and PublicKey
UDP
Protocol used for WireGuard's outer transport
51820
An example port for this guide, not a port used by every service

The examples below show field formats only; they aren't a configuration you can import or connect with. example.com is a sample domain, and the documentation address 2001:db8::10 isn't a real server endpoint. Use the address, port, and prefix assigned to your client.

Endpoint = example.com:51820
Address = 10.66.66.2/32

IPv6 Endpoint format:
[2001:db8::10]:51820

If Address is incorrect, outer authentication may still succeed, but the tunnel's source address won't match the range authorized for that Peer by the server. Requests may be sent without receiving valid responses. This differs from an unreachable Endpoint; the Home connection toggle alone can't tell you which layer is at fault.

DNS and AllowedIPs: Check name resolution, tunnel routing, and rules separately

DNS resolves domain names to IP addresses; it doesn't fix key authentication. If the Endpoint is a domain, the client must be able to resolve it before contacting the server. If the configured DNS is reachable only after the tunnel is established, check whether name resolution during startup depends on the tunnel. Don't use the Endpoint server address as DNS unless your provider confirms it also offers DNS resolution.

AllowedIPs defines address ranges for a WireGuard Peer. It isn't a domain rule or the client's Address. It affects routing within the tunnel and which peer is authorized for an address. Shadowrocket's Global Routing and Config determine how app requests are handled. Both layers must be set up correctly; checking only one isn't enough.

SettingWhat it meansHow to check
Address = 10.66.66.2/32The address this example client uses inside the tunnelCheck that it matches the address registered for this client on the server
AllowedIPs = 0.0.0.0/0The Peer’s IPv4 range covers all IPv4 addressesThis doesn't mean IPv6 is covered too
AllowedIPs = ::/0The Peer’s IPv6 range covers all IPv6 addressesThe server and tunnel address must also support IPv6
DOMAIN-SUFFIX,example.com,PROXYConfig selects the PROXY policy based on the domain suffixIt applies only when requests are handled by Config rules

If the original configuration includes AllowedIPs, preserve its meaning and check whether your import method carries this setting. Don't paste it into Address. If the editor has no corresponding field, check what the import format supports instead of guessing how fields map. DNS may also be affected by the DNS settings in the current Config. A DNS value in the entry doesn't guarantee that every system DNS request will use it.

Compare Global Routing modes: test the connection first, then restore your rules

After checking the WireGuard fields, confirm that test requests are actually using the entry. In Home → Global Routing, Proxy, Direct, and Config handle traffic in different ways. Scene applies preset behavior for a particular scenario; it isn't a fourth WireGuard encryption method. Note your original settings before testing, then restore them so a temporary mode doesn't become your permanent setup.

Config

Recommended

Handle requests using the rules and policies in the current Config. Rules such as DOMAIN-SUFFIX, IP-CIDR, and GEOIP affect matching; FINAL handles requests that didn't match earlier rules. The destination depends on how the rules are written, so unmatched requests aren't necessarily sent directly.

Best for: Restoring your normal rule-based routing after confirming the connection works.

Proxy

Use a proxy routing mode for requests handled by Shadowrocket to reduce the effect of Config rules during testing. Select the WireGuard entry you're testing, then check whether the same destination works. Check DNS separately.

Best for: Temporarily confirming that the WireGuard data path works.

Direct

Use a direct routing mode so regular requests aren't sent through the selected WireGuard entry. If a webpage loads in this mode, it only confirms that your local network works; it doesn't prove that WireGuard has established a working connection.

Best for: Checking your local network and isolating the tunnel as a factor.

If Proxy works but Config doesn't, first check which rule matched and its policy target; don't immediately regenerate your keys. If both fail, check the Endpoint, keys, and Address again. A latency test reflects only the response to that test; it can't replace a real request. Likewise, seeing the connection enabled in the system doesn't mean the remote peer has authenticated successfully.

How to set MTU: Test gradually, and only when symptoms point to it

MTU sets the maximum size of an individual packet inside the tunnel. WireGuard adds IP, UDP, and encryption overhead to the outer packets, so the usable tunnel size is typically smaller than the underlying link MTU. If your provider specifies a value, start with it. If not, keep the app's default behavior where possible; a single number found online isn't right for every network.

A common sign of an MTU mismatch is that small requests succeed, but larger responses, file transfers, or some TLS connections stall. Packet loss or server-side issues can cause similar symptoms, so compare results before drawing conclusions. If there's no working traffic at all, check the keys, Endpoint, and UDP reachability first instead of immediately setting a very low MTU.

  1. Record a baseline: Note the current MTU, network type, and test destination. On the same Wi-Fi or cellular network, retry the same page and a large file.
  2. Change one value at a time: For example, if the original configuration uses 1420, temporarily test 1380, then 1280 if needed. These are diagnostic test values, not server requirements or measured recommendations.
  3. Reconnect: Save the change and reconnect so the test uses the new setting. Don't change DNS, Endpoint, and Global Routing at the same time.
  4. Compare the results: If lowering MTU makes large responses stable while small requests were already working, record the result and ask your provider to check the network path. If it doesn't help, restore the original value and check other layers.

Results depend on whether the underlying connection uses IPv4 or IPv6, whether there are additional tunnels, and whether the network path filters required control packets. In particular, setting MTU below 1280 is unsuitable when the tunnel needs to carry IPv6. An MTU that's too small also increases fragmentation and processing overhead; “smaller is more stable” isn't a sound long-term tuning rule.

Common issues: Check the field that matches the symptom

The connection is enabled, but why can't I access anything?

First, confirm on Home that the WireGuard entry you're testing is selected, then use Global Routing → Proxy to test a real request. Check the Endpoint domain and UDP port, the client PrivateKey, and the server PublicKey in turn. Ask your provider to check whether it received a handshake from the client and whether the registered client public key matches.

Can I use the PublicKey instead of the PrivateKey?

No. Open the entry editor from Home and compare the original [Interface] and [Peer] sections to fill in the corresponding fields. If the private key is lost, follow your provider's process to reset the client identity and register the new public key. You can't recover the private key from an existing public key.

It works on my phone, but the connection keeps dropping when another device connects. Why?

Disconnect one device and compare. If each works on its own but they keep interrupting each other when connected simultaneously, check whether they share the same PrivateKey and Address. Get a separate set of settings for each device from your provider; don't try to fix this by changing only the last digit of Address.

Small pages load, but downloads keep stalling. What should I change first?

Keep the network, entry, and test file the same. Record the current MTU, then compare one value at a time, testing progressively lower values such as 1420, 1380, and 1280. Start with the value in the original configuration. If small requests fail too, check basic connectivity first. If only domain names fail, check DNS rather than attributing every issue to MTU.

When reporting an issue to your provider, include the network type, time of failure, Global Routing mode, and reproducible symptoms such as “domain lookup fails” or “small responses work but large ones stall.” You can share screenshots with sensitive fields hidden, but don't send your full PrivateKey, PresharedKey, or subscription link. For a refresher on Config and Home, see the user guide.

Get Shadowrocket and learn the basics

The iPhone / iPad version is available on the App Store for a one-time purchase of $2.99. The developer is Shadow Launch Technology Limited; check the App Store listing for system requirements. The Mac (Apple silicon / Intel), Windows, Android, and Linux versions are free. The cost of the app and any connection service from a provider are separate. Visit the download page to choose a platform, or read the setup and connection steps first.

Download Shadowrocket