V2Ray TLS Handshake Failed? Fix Certificate Errors, Clock Skew, SNI & allowInsecure

Troubleshoot V2Ray TLS certificate errors caused by incorrect system time, mismatched SNI and certificate names, or a wrong server name. Find the relevant client settings.

At a glance

Use this guide for nodes configured with standard TLS when the client logs show a handshake failure or an x509 certificate error. Check the raw error, system time, connection address and SNI, certificate chain, then client settings. Distinguish network timeouts from certificate verification failures, keep certificate verification enabled, and verify each change against fresh logs.

Distinguish certificate errors from connection failures

“TLS handshake failed” describes a stage, not a specific cause. The client first connects to the node’s address and port, then negotiates TLS and verifies the certificate, and only then starts the proxy protocol exchange. A connection timeout, a server-side disconnect, or a certificate name mismatch may all be reported as a connection failure. Expand the core logs and check the final cause in the error chain instead of relying on a failed status in the speed-test list.

In v2rayN, check the log area on the main screen for the current connection. In v2rayNG and v2flyNG, open Logs from the main menu. Menu labels may differ between releases. Note the client version, core, transport, and full error, then make one request through a single node so background connections don’t clutter the logs.

Error: x509: certificate has expired or is not yet valid

Cause: The system time falls outside the certificate’s validity period. The device clock may be wrong, or the server certificate may actually have expired. Fix: Sync the device clock first, then compare the current time in the logs with the certificate’s validity dates. If the error persists, the server operator must renew and reload the certificate.

Error: x509: certificate signed by unknown authority

Cause: The certificate chain cannot be traced to a trusted root certificate. Common causes include a missing intermediate certificate, a self-signed certificate, or an intercepted connection. Fix: Check the full server certificate chain and the device’s trust store, and verify the issuer. Don’t disable verification as a substitute for fixing the problem.

Error: tls: first record does not look like a TLS handshake

Cause: The target port isn’t returning the expected TLS data; it may be connecting to a plaintext service. Fix: Check the node’s port, transport security settings, and reverse proxy listener configuration.

Error: context deadline exceeded

Cause: The operation timed out. This message alone doesn’t indicate a certificate problem. Fix: Check the surrounding logs for DNS resolution, TCP connectivity, and the handshake stage. Don’t change certificate settings as a first step.

System time: sync it before checking certificate expiry

Certificates have a start date and an expiration date. A device clock set too early can trigger a “not yet valid” error; a clock set too late can make a valid certificate appear expired. Changing the time zone alone usually doesn’t change the underlying system timestamp. Correct the actual date and time. Check this first after switching between operating systems, starting a device that’s been off for a long time, or when automatic time sync has failed.

  1. Sync the clock

    Windows 11: Go to Settings → Time & language → Date & time, turn on Set time automatically, then select Sync now under Additional settings. If syncing fails, troubleshoot the device’s network connection first.

  2. Check other devices

    macOS: Go to System Settings → General → Date & Time and turn on Set time and date automatically. Android: Go to Settings → System → Date & time and turn on automatic time. Some manufacturers put this option under Additional settings.

  3. Reconnect

    After syncing the clock, stop and restart the client connection, then check the new error. Don’t use logs from before the clock was corrected to judge whether the fix worked.

  4. Check the certificate validity period

    If the device time is correct but the certificate still appears expired, check the validity dates of the certificate actually being served. After renewing a certificate, the TLS service must reload it; a new file on disk doesn’t mean active connections are using it yet.

Keep the connection address, SNI, and Host straight

The Address field in the node editor specifies where to connect. SNI is the server name sent in the TLS ClientHello, which the server often uses to select a certificate. For WebSocket, Host is an HTTP request header sent after the TLS handshake. These values may use the same domain or different ones, but they must match the server configuration. A “disguise domain” isn’t a decorative field you can change at will.

SettingStageWhat to check
Address and portNetwork connectionUse the endpoint provided by the server; DNS should resolve to the expected service.
serverName / SNITLS handshakeEnter a hostname covered by the certificate, without a scheme, port, or path.
WebSocket HostHTTP upgrade requestMatch the reverse proxy’s virtual host; this does not replace TLS SNI.
WebSocket pathHTTP path matchingUse the path specified by the server; a wrong path usually isn’t a certificate name error.
allowInsecureCertificate verificationKeep this set to false for standard publicly trusted certificates.

For example, using the documentation-only domain edge.example.com: if the certificate’s Subject Alternative Name includes that name, set SNI to the hostname—not https://edge.example.com/path. When connecting by IP, you can still explicitly set the server-required hostname as SNI. If you verify the certificate against the IP directly, the certificate must include a matching IP address entry; a domain name entry alone isn’t enough.

443
Common for HTTPS, but not a fixed port for every node
80
Common for plaintext HTTP; don’t enable TLS just because of the port

Rule of thumb: check the server settings, not the port number, to identify the protocol

Port numbers are conventions, not proof of the protocol. First confirm that the node actually uses standard TLS, then check SNI against the certificate name. Changing only the WebSocket Host can’t fix a certificate name mismatch that occurs before the HTTP request.

Where to check SNI and allowInsecure in your client

Labels vary between versions, so use the node editor and the actual field names below as a guide. Subscription updates may overwrite imported settings. Before making changes, duplicate the node for testing and note its original values. Don’t change the address, port, SNI, and transport all at once; even if the connection starts working, you won’t know what fixed it.

This standard TLS streamSettings snippet shows where the fields go; it isn’t a complete node configuration. The example uses TCP transport and a documentation-only domain. If your node uses WebSocket or another transport, don’t switch it to TCP just to match the example. Supported fields depend on the core actually in use.

{
  "streamSettings": {
    "network": "tcp",
    "security": "tls",
    "tlsSettings": {
      "serverName": "edge.example.com",
      "allowInsecure": false
    }
  }
}

Certificate chain and SNI: narrow it down with a separate handshake

If you have access to a terminal, you can inspect the certificate returned by the server independently, using the same device and network. These commands require OpenSSL to be installed. Replace the example hostname, SNI, and port with the actual values before running them. The connection address and SNI are passed separately, which is especially useful when connecting by IP but verifying against a domain name.

openssl s_client -connect edge.example.com:443 -servername edge.example.com -showcerts -verify_hostname edge.example.com -verify_return_error

If you receive a certificate from a different issuer only on one network, check for HTTPS inspection, a captive portal, or traffic redirection. Don’t install an unknown root certificate from an error dialog. If someone else manages the server, send them the redacted final error line, time of occurrence, SNI, and port. Don’t include the full subscription URL, UUID, or other credentials.

Common questions and how to verify a fix

If enabling allowInsecure lets me connect, can I leave it on?

It only means normal certificate verification is worth investigating; it doesn’t confirm a hostname problem. Sync the clock and check SNI, certificate validity, and the full chain. After fixing the cause, turn the option off and make a real request to verify the connection.

The node domain opens in a browser. Why does the client still report an error?

First check whether both use the same address, port, and SNI. The browser may use a different proxy or resolve to a different endpoint, and it may use a different trust store. Check the address the client actually connects to and the certificate it receives.

SNI reverts after a subscription update. What should I do?

Keep a separate copy for testing. Once you’ve confirmed the change works, ask the subscription provider to correct the settings they supply. Check the original node after each update so an automatic overwrite isn’t mistaken for a client that failed to save the change.

Should I check these TLS settings for a REALITY node too?

First check the actual value of security. REALITY doesn’t use the same certificate troubleshooting steps as standard TLS. Check the server-required serverName, public key, shortId, and other corresponding parameters. Don’t switch to standard TLS or enable certificate verification bypass as a guess.

After changing a setting, save the node, restart the connection, and repeat the same request. Don’t judge success by latency alone: the original certificate error should be gone from the logs, the request should complete, and certificate verification should remain enabled for standard TLS nodes. If the handshake succeeds but you see a path error, an unexpected HTTP status, or protocol authentication failure, investigate the transport path and account settings instead of changing SNI again.

Download clients