PHP says it cannot find the https wrapper
Warning: 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.
Fix it fast
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'));2Match what you see, then jump to its fix
- 1
stream_get_wrappers() lists http and ftp but not https, and extension_loaded('openssl') is falseThe openssl extension is not enabled in php.iniFix - 2
The 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
The 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
- 1
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.ini2Fix
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
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 --ini2Fix
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 opensslConfirmed by php.net
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*.dll2Fix
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\php3Verify
Start PHP from a new terminal and list the loaded modules.
php -m | findstr /i opensslConfirmed by php.net
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
Apache returns 503 or 504 because PHP-FPM did not answer in time
Error dispatching request
Apache sent the request to PHP-FPM and gave up waiting.
3 causes, each with a fixBack end
AWS SDK for PHP cannot get credentials from the instance profile metadata server
Error retrieving credentials from the instance profile metadata server.
The SDK tries the EC2 instance metadata service when it has no valid credentials from anywhere earlier in its chain.
4 causes, each with a fixBack end
AWS SDK for PHP rejects requests: the signature is from the future
Signature not yet current: {date} is still later than {date}
AWS compares the timestamp in your signed request with its own clock.
2 causes, each with a fixBack 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 fixBack 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 fixBack end
CodeIgniter 3 stops with "Your system folder path does not appear to be set correctly"
503 Service Unavailable
CodeIgniter 3's front controller resolves $system_path and then checks that the result is a directory.
3 causes, each with a fix