How to Configure a Trojan Server in Shadowrocket: Password, SNI & TLS Settings

When configuring Trojan in Shadowrocket, Address and Port determine where to connect, SNI identifies the server name during the TLS handshake, and Password is used for Trojan authentication. This guide explains how to enter each value in Add Server and distinguish connection failures, certificate mismatches, and authentication errors after saving.

At a glance

This guide is for users who already have Trojan connection details and need to enter them manually or check an imported profile. Follow the Add Server fields in order—Address, Port, Password, and TLS settings—then use the error messages to determine whether the issue is with establishing the connection, certificate validation, Trojan authentication, or rule-based routing after connecting.

Trojan settings: Address, Port, Password, and SNI

The examples below use standard Trojan over TLS. Before you begin, make sure the provider supplied the protocol, address, port, and password for the same profile, and check whether an SNI or transport type is specified separately. If the details come from your own subscription, verify each value against the same entry; don’t combine an address from one endpoint with a password from another. The domain and port below are examples of the expected format only.

443
Common TLS ports; enter the port the server actually listens on
2 values
Address and Port together specify the connection destination
1 server name
For SNI, enter only the domain—no port or path
FieldWhat to enterCommon mistakes
AddressThe connection domain or IP address provided by your service provider, such as entry.example.com.Including https://, a path, or a port in the address field.
PortThe port the server listens on, such as 443 or 8443.Entering 443 just because TLS is used, instead of the port actually provided.
PasswordThe original password for this Trojan entry. Preserve capitalization and punctuation.Entering the password for the provider’s website, a token from a subscription URL, or extra quotation marks, spaces, or line breaks copied with the password.
SNIThe TLS server name specified by your provider, such as tls.example.com.Entering the domain of the website you want to visit, or copying the IP from Address into SNI just because Address is an IP.

For example, the provider gives you entry.example.com as Address, 8443 as Port, and tls.example.com as SNI. Enter each value in its corresponding field. The connection still goes to entry.example.com:8443; SNI does not change the destination to tls.example.com.

Add Server: manual setup

  1. Select Trojan

    Open Home → tap + in the top-right corner to open Add Server. Open Type, select Trojan, and fill in the fields for that protocol.

  2. Enter Address and Port

    Enter the hostname or IP in Address and the port separately in Port. If you only have a complete share link, import it first, then open the entry’s edit screen to check the fields instead of pasting the entire link into the address field.

  3. Check the exact password

    Enter the Trojan password provided by your service provider in Password; there’s no need to convert it to a hash. If you have the password in a parameter list, enter it as given. If it comes from a share link, don’t treat the escaped text in the URI as the original password or decode it again after importing.

  4. Check the TLS settings

    Standard Trojan uses TLS. If the edit screen has a TLS switch, leave it enabled; if there’s no separate switch, you don’t need to create a TLS configuration. Enter the SNI provided by your service provider. Don’t enable certificate verification bypass to try to fix connection issues. If the details specify a transport type, ALPN, or path, enter those values for the same entry as well.

  5. Save and test

    Tap Save, return to Home, and make sure the entry you just saved is selected before running Connectivity Test. If the test passes, turn on the connection and verify it in an app. If you have entries with the same name, give them distinct display names so you don’t test the wrong profile.

TLS certificate validation: options and when to use them

A correctly entered address only shows that the connection is going to the expected endpoint; it doesn’t verify the server’s identity. Standard TLS validation also checks that the certificate chain is trusted, the certificate is within its validity period, and the server name used for validation is covered by the certificate. If the server selects a certificate based on SNI, an incorrect name may return a certificate for another site. Reaching the right IP and matching the certificate name are separate checks.

Keep certificate validation enabled

Recommended

Use the correct server name for the configuration and keep standard certificate checks enabled. If the certificate doesn’t match or its chain isn’t trusted, first check the system date, SNI, and the current settings provided by your service provider.

Best for: everyday connections and initial setup

Skip certificate validation

TLS encryption and server identity validation are separate. Skipping validation disables standard certificate identity checks and won’t fix an incorrect server name, port, or password.

Best for: understanding the option in a controlled test, not for everyday connections

If you get a certificate error, check the server name first

If the connection address is an IP and your service provider gave you a separate TLS domain, keep the IP in Address, enter the specified domain in SNI, and try again. If the certificate error persists, ask your service provider to check the error type and time it occurred. Don’t include your password or subscription URL.

Trojan connection failed: troubleshooting by error

It timed out right after setup. Does that mean the password is wrong?

A timeout alone doesn’t prove that the password is wrong. If the message says the domain couldn’t be resolved, check the spelling in Address. If it resolves but the connection times out, check Port, then switch to another available network and test the same entry again. Change one value at a time so you can tell whether the cause is the network or the configuration.

My provider didn’t specify SNI. Can I use Address?

Don’t enter an unrelated domain. If Address is already a domain and the configuration doesn’t list SNI separately, keep the imported value or the edit screen’s default behavior. If Address is an IP and you get a certificate name mismatch, ask your service provider which TLS server name to use.

Authentication failed. Which setting should I change?

Once you’ve confirmed the message refers to Trojan authentication, check Type and Password for the same entry. Check capitalization, extra whitespace from copying, and whether the password is outdated. If the entry came from your own subscription, make sure Home has the updated entry selected—not an older manually saved one.

The test passed. Why is my app still using a direct connection?

Check Global Routing on Home. Direct sends traffic directly. Under Config, check the first rule matching the destination domain in the active configuration, along with the policy set by the final FINAL rule. A successful connection test doesn’t mean the target app’s requests matched a proxy policy.

How the connection works: TLS first, then Trojan authentication

Standard Trojan over TLS carries authentication and forwarding requests inside a TLS connection. In practical terms, Shadowrocket first connects to the proxy endpoint, negotiates encryption and validates the server’s identity during the TLS handshake, then sends the Trojan request. SNI is part of the TLS handshake, not the password. It identifies the proxy server, not the website you ultimately want to visit.

  1. Connect to the endpoint. If Address is a domain, Shadowrocket resolves it first, then opens a TCP connection to the resolved address and Port. If this step fails, changing Password won’t make the port reachable.
  2. Establish TLS. The client sends the configured server name and checks the server certificate. If the error mentions an expired certificate or a name mismatch, troubleshoot this layer first; don’t infer from the error whether the Trojan password is valid.
  3. Authenticate the Trojan request. Once TLS is established, the server can process Trojan authentication and forwarding requests inside the encrypted connection. A closed connection doesn’t necessarily mean the password is wrong. If there’s no explicit error, compare the test result with the server logs for the same time period.
Download Shadowrocket for all platforms