Fixing 'WordPress Could Not Establish a Secure Connection' on Localhost
Content
If you're developing on a local server like XAMPP, Laragon, or WAMP, you've likely encountered this frustrating error message: Warning: An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration... (WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)
This error prevents you from browsing, installing, or updating plugins and themes directly from your WordPress dashboard. Based on numerous community reports, this is a common localhost configuration issue, not a problem with WordPress.org. This guide will walk you through the most effective solutions.
Why This Happens on Localhost
Your local development environment (e.g., XAMPP, Laragon, WAMP) needs to be configured correctly to allow WordPress to make outbound secure (HTTPS) requests to api.wordpress.org. The error typically occurs when the required PHP extensions for these requests are missing, disabled, or misconfigured.
Most Common Solutions
1. Enable and Verify PHP cURL & OpenSSL Extensions
The vast majority of these connection errors are due to the cURL extension not being active. This is essential for WordPress to communicate with external servers.
- Locate your
php.inifile. This is usually found in your local server's PHP directory (e.g.,C:xamppphpphp.iniorC:laragonbinphpphp-[version]php.ini). - Open the file in a text editor and search for the following lines:
;extension=curl;extension=openssl - Remove the semicolon (
;) from the beginning of each line to enable them. They should look like this:extension=curlextension=openssl - Save the
php.inifile and restart your local server (Apache, MySQL) completely. - Verify the extensions are loaded by creating a
phpinfo.phpfile in your root directory with the code<?php phpinfo(); ?>. Access it in your browser (e.g.,http://localhost/phpinfo.php) and search for 'curl'.
2. Check for External Connection Blocking (Less Common)
Some users have tried adding define('WP_HTTP_BLOCK_EXTERNAL', true); to their wp-config.php file for other reasons, which blocks all external HTTP requests. Ensure this line is not present in your configuration, or if it is, set it to false.
3. Increase PHP's Execution Time (For Timeout Errors)
If your error is accompanied by Fatal error: Maximum execution time of 30 seconds exceeded, your server is timing out while trying to connect. Increase the time limit in your php.ini file.
- Find and modify these values in
php.ini:max_execution_time = 120max_input_time = 120 - Save the file and restart your server.
4. Manual Installation: A Reliable Workaround
If configuration changes prove difficult, you can always install plugins and themes manually. This is a reliable fallback method for local development.
- Download the plugin or theme ZIP file from WordPress.org.
- Extract the ZIP file.
- Copy the extracted folder into your WordPress installation's
wp-content/pluginsorwp-content/themesdirectory. - Go to your WordPress admin dashboard under Plugins or Appearance > Themes to activate it.
Conclusion
In most cases, the 'secure connection' error on localhost is resolved by simply enabling the PHP cURL extension. If you continue to experience issues, the manual installation method is an effective way to continue your work without interruption. For further reading, the official PHP documentation on installing cURL is an excellent resource.
Related Support Threads Support
-
Ошибка! Error!https://wordpress.org/support/topic/%d0%be%d1%88%d0%b8%d0%b1%d0%ba%d0%b0-error/
-
Missing REST API and Translation Controller Classeshttps://wordpress.org/support/topic/missing-rest-api-and-translation-controller-classes/
-
Plugin Installation Not Working on LocalHosthttps://wordpress.org/support/topic/plugin-installation-not-working-on-localhost/
-
WordPress could not establish a secure connection to WordPress.orghttps://wordpress.org/support/topic/wordpress-could-not-establish-a-secure-connection-to-wordpress-org-8/
-
when i download plugins there is a fatal error i cant solvehttps://wordpress.org/support/topic/when-i-download-plugins-there-is-a-fatal-error-i-cant-solve/
-
XML – Sorry, this file type is not permitted for security reasons.https://wordpress.org/support/topic/xml-sorry-this-file-type-is-not-permitted-for-security-reasons/
-
Installing pluginshttps://wordpress.org/support/topic/installing-plugins-21/
-
WordPress modules (exif and imagick) do not match by new Php 4.4 in laragonhttps://wordpress.org/support/topic/wordpress-modules-exif-and-imagick-do-not-match-the-new-php-4-4-kernel-in-loca/
-
Can search for plugins and themes and everything is slow.https://wordpress.org/support/topic/can-search-for-plugins-and-themes-and-everything-is-slow/
-
Parse errorhttps://wordpress.org/support/topic/parse-error-514/
-
Fix: dokan and woocommerce crashes my site when ever i install both of the. dokan lite/core i mean.https://wordpress.org/support/topic/fix-dokan-and-woocommerce-crashes-my-site-when-ever-i-install-both-of-the-dokan-lite-core-i-mean/
-
Warning: undefined array key … in wp-cli.phar on line 213https://wordpress.org/support/topic/warning-undefined-array-key-in-wp-cli-phar-on-line-213/
-
WordPress could not establish a secure connection to WordPress.org. Please contahttps://wordpress.org/support/topic/wordpress-could-not-establish-a-secure-connection-to-wordpress-org-please-conta-4/
-
Permanent connection errors to WordPress.orghttps://wordpress.org/support/topic/permanent-connections-errors-to-wordpress-org/
-
Installation failed: There has been a critical error on your website. Please chehttps://wordpress.org/support/topic/installation-failed-there-has-been-a-critical-error-on-your-website-please-che/
-
PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect()https://wordpress.org/support/topic/php-fatal-error-uncaught-error-call-to-undefined-function-mysql_connect/
-
plugin fatal error instalhttps://wordpress.org/support/topic/plugin-fatal-error-instal/
-
What need does WordPress have for communication with wordpress.orghttps://wordpress.org/support/topic/what-need-does-wordpress-have-for-communication-with-wordpress-org/
-
WooCommerce not downloadiighttps://wordpress.org/support/topic/woocommerce-not-downloadiig/
-
WordPress 6.4 Issue with Php 8.2https://wordpress.org/support/topic/wordpress-6-4-issue-with-php-8-2/
-
Fatal error: Uncaught Error: Call to undefined function wc_get_orders()https://wordpress.org/support/topic/fatal-error-uncaught-error-call-to-undefined-function-wc_get_orders/
-
Fatal error: Uncaught Error: Undefined constant GuzzleHttpClientInterface:https://wordpress.org/support/topic/fatal-error-uncaught-error-undefined-constant-guzzlehttpclientinterface/
-
“Mancano uno o più moduli obbligatori”https://wordpress.org/support/topic/mancano-uno-o-piu-moduli-obbligatori/
-
Error installing pluginshttps://wordpress.org/support/topic/error-installing-plugins-3/
-
Update failed: Download failed. No working transports foundhttps://wordpress.org/support/topic/update-failed-download-failed-no-working-transports-found-2/
-
Error install pluginhttps://wordpress.org/support/topic/error-install-plugin-2/
-
WP MU-Migration in Laragonhttps://wordpress.org/support/topic/wp-mu-migration-in-laragon/
-
wp cli command doesn’t work, back the Fatal error mysql_connect()https://wordpress.org/support/topic/wp-cli-command-doesnt-work-back-the-fatal-error-mysql_connect/