In some occasions, such as when setting up a development WordPress installation on a local computer for testing, there may be a need to use a proxy server to access the Internet to perform external HTTP, HTTPS and other calls or requests, especially for corporate and enterprise environment where most servers sit behind proxy. For example, WordPress tends to check for updates automatically, need to download and install new theme or plugin, license activation for premium plugin or theme, and etc.
When WordPress attempts to connect to Internet, but failed to do so as Internet is not available, the following error message may appear:
An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums.
If your LAN uses proxy server to connect to Internet, WordPress has built-in API support for HTTP proxy. To add proxy server configuration to WordPress so that the outgoing HTTP connection made by WordPress is passed to proxy server, add the following constants and values to wp-config.php in the root of the WordPress installation.
/* Configure HTTP Proxy Server */ define('WP_PROXY_HOST', '192.168.1.1'); define('WP_PROXY_PORT', '3128'); define('WP_PROXY_USERNAME', ''); define('WP_PROXY_PASSWORD', ''); define('WP_PROXY_BYPASS_HOSTS', 'localhost');
Replace the 192.168.1.1 with actual IP address or host name of proxy server, and 3218 with actual port number of the proxy server. You may want to define the WP_PROXY_USERNAME and WP_PROXY_PASSWORD if your proxy server requires authentication.
The definition of various WordPress’ proxy related constants:
- WP_PROXY_HOST – Enable proxy support and set the host for connecting (must be defined).
- WP_PROXY_PORT – Proxy port for connection (must be defined).
- WP_PROXY_USERNAME – Proxy username, if it requires authentication.
- WP_PROXY_PASSWORD – Proxy password, if it requires authentication.
- WP_PROXY_BYPASS_HOSTS – Skip proxy for hosts (in comma separated list) in the list from going through the proxy. Wildcards using * are supported, eg. *.wordpress.org (localhost is not passed through proxy by default so not necessary to appear in the list).
By configuring proxy server in WordPress, and Windows or Linux environment itself is not altered or changed, and continue to work as it’s.
In addition, if you’re unsure of network configuration for proxy server, you can check the web browser’s config on the web browser that can browse the World Wide Web, and apply the same settings to wp-config.php.