To fix an SSL handshake failed error, you must ensure that the server and the client agree on a supported TLS protocol version and a matching cipher suite, while verifying that the SSL certificate is valid and correctly installed. This error occurs when the initial "handshake"—the process where the client and server introduce themselves and negotiate security parameters—fails to complete, preventing a secure connection from being established.
What You'll Need
- Administrative access to your server (SSH or Control Panel).
- Access to your SSL certificate files (.crt, .key, and often a CA-bundle/intermediate file).
- A browser or command-line tool (like OpenSSL or cURL) for testing.
- Access to your web server configuration files (e.g., nginx.conf or httpd.conf).
Step-by-Step
- Verify Certificate Validity and Expiration: The most common cause of a handshake failure is an expired or mismatched certificate. Use an online SSL checker or a command-line tool to see if the certificate is still valid. If the certificate has expired, the browser will terminate the handshake immediately. Check that the Common Name (CN) or Subject Alternative Name (SAN) on the certificate exactly matches the domain name you are using to access the server. If you are using a wildcard certificate, ensure the subdomain is correctly covered.
-
Check TLS Protocol Version Compatibility:
Handshake failures often happen because the server is configured to use an old protocol (like TLS 1.0 or 1.1) that the client has disabled for security reasons, or the server is using TLS 1.3 while the client only supports 1.2. Open your server configuration file. For Nginx, look for the
ssl_protocolsdirective; for Apache, look forSSLProtocol. Ensure that TLS 1.2 and TLS 1.3 are enabled. Disable SSLv2 and SSLv3 entirely, as these are deprecated and insecure. Note that labels and paths for these settings can differ slightly depending on your operating system version or the specific distribution of the web server software you are using. -
Audit and Update Cipher Suites:
Even if the protocol version matches, the handshake will fail if the server and client cannot agree on a cipher suite (the set of algorithms used to encrypt the data). If your server is configured with highly restrictive ciphers that the client doesn't support, the connection will drop. Review your
ssl_ciphers(Nginx) orSSLCipherSuite(Apache) settings. Use a recognized standard, such as the Mozilla SSL Configuration Generator, to find a compatible list of ciphers that balances security with broad compatibility across different browsers and devices. - Validate the Certificate Chain (Intermediate Certificates): A server must provide not just its own certificate, but also the intermediate certificates that link it back to a trusted Root Certificate Authority (CA). If the intermediate chain is missing or incomplete, some clients (especially mobile devices and certain API clients) will fail the handshake because they cannot verify the trust path. Ensure you have concatenated your server certificate and the intermediate certificates into a single "fullchain" file and that your server configuration points to this combined file rather than just the individual server certificate.
-
Check Server Time and Date:
SSL/TLS certificates are time-sensitive. If your server's system clock is significantly out of sync with the actual time, it may perceive a valid certificate as not yet valid or already expired. Use the
datecommand in Linux to check the current system time. If it is incorrect, synchronize it using NTP (Network Time Protocol) to ensure the timestamps on the certificates are interpreted correctly during the handshake process. - Inspect Firewall and Port Settings: Ensure that port 443 (the standard port for HTTPS) is open and not being intercepted by a firewall or a proxy that does not support the negotiated TLS version. Some deep packet inspection (DPI) firewalls attempt to intercept the handshake to scan for threats; if the firewall doesn't support the specific cipher or protocol the server is using, it will trigger a handshake failure. Temporarily disable the firewall or create an explicit allow rule for port 443 to rule this out.
-
Restart the Web Server:
Configuration changes to SSL/TLS settings do not take effect until the service is reloaded. After modifying your protocol versions or cipher suites, restart your server. For Nginx, use
systemctl restart nginx; for Apache, usesystemctl restart apache2orhttpd. Always run a configuration test (e.g.,nginx -t) before restarting to ensure there are no syntax errors that could crash the server.
Common Mistakes
One of the most frequent mistakes is installing the server certificate but forgetting the intermediate CA bundle. While some desktop browsers can automatically fetch missing intermediates, many mobile apps and command-line tools cannot, leading to intermittent "Handshake Failed" errors that are hard to diagnose. Another common error is using a self-signed certificate in a production environment without informing the client; since the client cannot verify the certificate against a trusted root, the handshake is often rejected as an untrusted connection.
Additionally, administrators often over-harden their servers by disabling too many ciphers in an attempt to achieve a "perfect" security score. This can inadvertently lock out older but still widely used clients, such as legacy enterprise software or older smartphone operating systems, resulting in a handshake failure for those specific users while everything seems fine for the administrator using a modern browser.
Tips
To prevent these issues in the future, implement automated certificate renewal using tools like Certbot for Let's Encrypt. This eliminates the risk of handshake failures caused by expired certificates. Always keep your server software updated; newer versions of Nginx and Apache include updated libraries (like OpenSSL) that support the latest, most secure TLS versions and ciphers by default.
When testing, use a variety of clients. Do not rely solely on your own browser, as your browser may have cached a previous successful handshake or may have specific settings that hide errors. Test with a different browser, a mobile device on a cellular network, and a tool like cURL to ensure the server is behaving consistently across different environments.
Troubleshooting
If the handshake still fails after following the steps above, start by checking the server's error logs. For Nginx, these are typically found in /var/log/nginx/error.log; for Apache, check /var/log/apache2/error.log. Look for specific error codes like "SSL_do_handshake() failed" or "no shared cipher." These logs will tell you exactly which part of the process failed.
If the logs are vague, use OpenSSL to simulate a handshake from the command line. Run openssl s_client -connect yourdomain.com:443 -tls1_2. This command forces the use of TLS 1.2 and provides a detailed output of the handshake process, including the certificate chain provided by the server and the cipher selected. If this command works but the browser doesn't, the issue is likely with the client's browser settings or a local proxy. If this command fails, the issue is definitively on the server side, likely related to the protocol or cipher configuration.
Finally, if you are using a Load Balancer or a Content Delivery Network (CDN) like Cloudflare, remember that the SSL handshake happens twice: once between the client and the CDN, and once between the CDN and your origin server. A "Handshake Failed" error could be happening at either point. Check your CDN settings to see if the "SSL/TLS encryption mode" (e.g., Full, Strict, or Flexible) matches the certificate configuration on your origin server.
Frequently Asked Questions
Does a handshake failure mean my server was hacked?
No, an SSL handshake failure is almost always a configuration issue related to protocol versions, expired certificates, or mismatched ciphers. It is a failure to establish a secure connection, not necessarily an indication of a breach.
Can a slow internet connection cause a handshake failure?
Yes, in some cases. If the network latency is extremely high or there is significant packet loss, the handshake packets may time out before the process completes, leading the client to report a handshake failure.
What is the difference between an SSL error and a handshake failure?
An SSL error is a general term for any problem with the secure connection. A handshake failure is a specific type of SSL error that occurs during the initial negotiation phase, before any actual data is encrypted and sent.
Do I need to change my certificates to support TLS 1.3?
Not necessarily. TLS 1.3 is a protocol version handled by the server software and the OpenSSL library. As long as your certificate is signed with a modern algorithm (like RSA 2048-bit or ECDSA) and your server software is updated, you can enable TLS 1.3 without issuing new certificates.
Why does the site work in Chrome but fail in Safari?
Different browsers have different default security policies and supported cipher suites. Safari may require a more modern cipher or a complete certificate chain that Chrome is able to resolve automatically via its own internal database of root certificates.