| Feature | Details |
|---|---|
| Error Code | [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1020) |
| Environment | Python 3.13 (macOS, Linux, Windows) |
| Primary Cause | Missing CA root certificates or network interception during WiFi instability. |
| Quick Fix | Run “Install Certificates.command” (macOS) or update certifi. |

What is Python 3.13 SSL Certificate Verify Failed?
The “Python 3.13 SSL certificate verify failed” error is a security safeguard. It occurs when Python’s ssl module cannot verify the authenticity of a server’s TLS certificate. This usually happens because the local system lacks the necessary Certificate Authority (CA) bundle.
In the context of Python 3.13, this error is frequently triggered by unstable WiFi connections. When a connection drops or is hijacked by a captive portal (common in public WiFi), the SSL handshake is interrupted. This leads to a verification failure because the intercepted data does not match the expected certificate chain.
Additionally, Python 3.13 on macOS does not use the system’s Keychain for certificates by default. It relies on its own internal bundle or a third-party package like certifi. If these bundles are outdated or missing, all HTTPS requests will fail.
Step-by-Step Solutions
1. Run the macOS Certificate Command
If you are using Python 3.13 on macOS, the most common fix is running the bundled command script. This script installs a set of root certificates from the certifi package into your Python environment.
# Navigate to your Python 3.13 folder and run:
/Applications/Python\ 3.13/Install\ Certificates.command
2. Upgrade the Certifi Package
The certifi package provides Mozilla’s carefully curated collection of Root Certificates. Ensuring this is up to date often resolves verification issues caused by new or updated web certificates.
pip install --upgrade certifi
3. Set Environment Variables
Sometimes Python fails to locate the certificate store. You can manually point Python to the correct CA bundle by setting an environment variable. This is particularly helpful in corporate environments with custom firewalls.
# For Linux/macOS
export SSL_CERT_FILE=$(python3 -m certifi)
# For Windows (PowerShell)
$env:SSL_CERT_FILE=$(python -m certifi)
4. Handle WiFi Instability
If the error occurs specifically during “WiFi Drops,” your scripts should include retry logic. This prevents the application from crashing when the network momentarily switches to a captive portal or loses signal.
# Example using requests with retries
import requests
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry
session = requests.Session()
retries = Retry(total=5, backoff_factor=1, status_forcelist=[502, 503, 504])
session.mount('https://', HTTPAdapter(max_retries=retries))