Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

PHP says it cannot find the https wrapper

ErrorWarning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP?

Short answer

PHP registers the https:// wrapper only when its openssl extension is loaded. The warning means the PHP that ran your script has no openssl. Check which wrappers it has, then enable openssl in the php.ini that PHP really loads, make sure the OpenSSL DLLs are found on Windows, and restart the web server.

  • Applies to PHP 8.3, XAMPP on Windows, Apache 2.4, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Print the stream wrappers the running PHP has registered. If https is not in the list, openssl is not loaded in that PHP. Run it once from a web page, because the command line PHP can differ from the one Apache uses.

    <?php
    print_r(stream_get_wrappers());
    var_dump(extension_loaded('openssl'));
  2. 2Match what you see, then jump to its fix

    1. 1stream_get_wrappers() lists http and ftp but not https, and extension_loaded('openssl') is falseThe openssl extension is not enabled in php.iniFix
    2. 2The line is already enabled in the file you edited, but phpinfo() still shows openssl missingYou edited a php.ini that Apache does not readFix
    3. 3The extension line is enabled but PHP fails to load php_openssl.dll at start, or openssl stays missingOn Windows, the OpenSSL DLLs cannot be foundFix

What does the error look like?

  • Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP?
  • Warning: fopen(): Unable to find the wrapper "https"

Cause 1 of 3

The openssl extension is not enabled in php.ini

1Check

The manual says https is supported only when the openssl extension is enabled. Look for the extension line in the loaded php.ini.

php --ini
grep -n "openssl" /path/to/php.ini

2Fix

Remove the leading semicolon from the extension line (on Windows it is the php_openssl.dll line), and make sure extension_dir points at the folder that holds the DLLs. Save the file and restart the web server.

; Windows php.ini
extension=php_openssl.dll
extension_dir = "C:/xampp/php/ext"

3Verify

Reload the test page. https should now be in the wrapper list.

php -r "var_dump(in_array('https', stream_get_wrappers()));"

Confirmed by php.net

Did this fix it?

Cause 2 of 3

You edited a php.ini that Apache does not read

1Check

Open a page that calls phpinfo() and read the Loaded Configuration File row. The CLI and the Apache module can use different files, and Apache can pick a file by PHPIniDir or PHPRC. Delete the test page after you look.

<?php phpinfo();
// CLI view of the same question:
// php --ini

2Fix

Edit the file named in that row, or point Apache at the one you want with PHPIniDir. PHP reads php.ini once at web server start for the Apache module, so restart Apache after every edit.

# httpd.conf
PHPIniDir "C:/xampp/php"

3Verify

Restart Apache from its control panel or service, then reload the phpinfo page and find the openssl section.

php -m | grep -i openssl

Confirmed by php.net

Did this fix it?

Cause 3 of 3

On Windows, the OpenSSL DLLs cannot be found

1Check

php_openssl.dll needs the libcrypto and libssl DLLs (OpenSSL 1.1 and later) on the system PATH. Windows searches the directory of the host program first, which under Apache is Apache's bin folder.

where libssl*.dll
where libcrypto*.dll

2Fix

Put the PHP folder on PATH rather than copying DLLs around, then open a new terminal or restart the Apache service. The manual recommends PATH over copying files into System32.

set PATH=%PATH%;C:\xampp\php

3Verify

Start PHP from a new terminal and list the loaded modules.

php -m | findstr /i openssl

Confirmed by php.net

Did this fix it?

How do I stop it coming back?

  • Keep a throw-away phpinfo page in your toolbox and check the Loaded Configuration File row before editing any php.ini.
  • Restart Apache or PHP-FPM after every php.ini change, because the server reads it only at start.
  • Check stream_get_wrappers() after installing or upgrading PHP, before deploying code that calls an https URL.
  • On Linux, install PHP from your distribution packages or a build with openssl; a PHP compiled by hand needs --with-openssl.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

CodeIgniter 4 cannot write its cache files

CodeIgniter\Cache\Exceptions\CacheException: Cache unable to write to /var/www/app/writable/cache/

CodeIgniter 4's file cache needs a cache directory that the web server can really write to.

2 causes, each with a fix

Back end

CodeIgniter 3 loads the model but the property is undefined

The model name you are loading is the name of a resource that is already being used: user

CodeIgniter 3 expects a model file named like its class, with the first letter capitalised, for example User_model.php holding class User_model.

2 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.