Unable to find the socket transport "https"

Unable to find the socket transport "https"

  1. Blog
  2. 15 November 2026
  3. 4 min read

Stefan Bogdanescu

Founder & Senior Architect

Fixing "Unable to find the socket transport 'https'" in PHP

The error message Unable to find the socket transport "https" - did you forget to enable it when you configured PHP? is a classic indicator that your PHP installation lacks native SSL/TLS support, or more specifically, the cURL extension has not been compiled with OpenSSL. This often trips up developers working on Windows environments like IIS, where the default build process frequently omits SSL libraries unless explicitly requested.

The root cause isn't that your server can't handle HTTPS; it's that PHP doesn't know how to initiate a secure socket connection using its standard library functions. When you run fsockopen() directly with an HTTPS URL, or when you attempt to use cURL without the necessary extensions, PHP falls back to generic socket handling, which fails because it cannot resolve the encryption handshake required for port 443.

The Role of cURL and OpenSSL

The error log explicitly mentions that SSL is present in your phpinfo() output but only under IMAP and cURL. This is a critical distinction. While having the SSL module loaded allows protocols like IMAPS (port 993) to work, it does not automatically enable HTTPS support for web requests unless the cURL extension itself was compiled with the --with-openssl flag.

To resolve this, you must ensure that the cURL extension is available and linked against an OpenSSL library. If you are managing a custom PHP build on IIS or another Windows server, check your php.ini for the following lines:

extension=php_curl.dll
extension=php_openssl.dll

If these lines exist but are commented out, uncomment them. However, if the extensions are loaded and you still see the error, it usually means the cURL extension was built without OpenSSL support. In a production environment, you cannot simply "add" OpenSSL to an existing binary; the library must be compiled into the extension during the build process.

Switching to Native PHP Streams

If you are constrained by your hosting environment and cannot recompile or replace the PHP binaries to include cURL with OpenSSL, you can bypass the fsockopen() limitation entirely by using PHP's native stream wrappers. Modern PHP versions (5.5+) include support for SSL streams built into the core, independent of cURL.

Instead of calling fsockopen(), use fopen() with the ssl:// prefix:

$url = 'https://example.com/soapserver.php';
$context = stream_context_create([
    'ssl' => [
        'verify_peer' => true,
        'verify_peer_name' => true,
        'cafile' => '/path/to/cacert.pem', // Adjust path based on OS
    ]
]);

$fp = fopen($url, 'r', false, $context);

if ($fp) {
    echo "Connection successful";
} else {
    echo "Connection failed: " . stream_get_meta_data($fp)['wrapper_type'];
    fclose($fp);
}

This approach utilizes the openssl extension directly via the stream layer. It is often more robust than trying to force cURL or raw sockets when SSL support is missing from the curl stack. If your server administrator confirms that OpenSSL DLLs are present but not linked to cURL, switching to this native stream method is a viable workaround for simple connectivity checks.

When to Use LaravelCompany Solutions

For complex integrations where you need full control over SSL contexts, timeouts, and headers, sticking to standard extensions like cURL or the native stream wrapper is the industry standard. However, if your project is built on the Laravel framework and requires sophisticated HTTP client management beyond what raw PHP streams offer, consider leveraging specialized packages or frameworks designed for this purpose. Resources such as https://laravelcompany.com often highlight best practices for handling API integrations within modern stacks, emphasizing the use of dedicated HTTP clients that abstract away these lower-level socket details.

Verifying Your Configuration

Before declaring a failure, always inspect your active extensions. Run php -m in your terminal or server console to list loaded modules. If you do not see curl or openssl in the output, neither extension is currently active. If they are listed but the error persists with cURL, verify the OpenSSL library path via phpinfo(). Look for the "OpenSSL" section; if it is missing despite the DLL being loaded, the configuration is broken.

In many IIS deployments, the issue stems from a mismatch between the PHP version and the available system libraries. Ensure that your PHP binaries match the architecture (x64 vs x86) of your server and that the OpenSSL DLLs are accessible to the PHP runtime. If reconfiguration is impossible, the native ssl:// stream wrapper remains the most reliable fallback for establishing secure connections without relying on cURL's specific implementation.

Our network