wp-content » plugins » MonsterInsights – The firewall of your server is blocking outbound calls. Please contact your hosting provider to fix this issue.

MonsterInsights – The firewall of your server is blocking outbound calls. Please contact your hosting provider to fix this issue.

2023 12 13 09 23 1024x505 - MonsterInsights - The firewall of your server is blocking outbound calls. Please contact your hosting provider to fix this issue.

MonsterInsights Error: The firewall of your server is blocking outbound calls. Please contact your hosting provider to fix this issue. cURL error 28: Failed to connect to www.google.com port 443 after 1201 ms: Couldn’t connect to server

2023 12 13 09 24 - MonsterInsights - The firewall of your server is blocking outbound calls. Please contact your hosting provider to fix this issue.

This error is caused by cURL (Client for URLs) – a command line tool that is used to transfer data to and from a server. To fix the error first check if curl is available in your php.info file:


Check if curl is enabled

Create a new file info.php in your website folder with the following content:

<?php
phpinfo();
?>

Save the file and open it in your browser: example.com/info.php

Then search for “curl” and if you see the section then curl is enabled and working:

2023 12 13 09 40 1024x452 - MonsterInsights - The firewall of your server is blocking outbound calls. Please contact your hosting provider to fix this issue.

Another way to test if curl is enabled is directly from the terminal:

curl -V

You should see the version if curl is enabled:

2023 12 13 09 44 - MonsterInsights - The firewall of your server is blocking outbound calls. Please contact your hosting provider to fix this issue.

After we have confirmed that curl is enabled, lets test outgoing connections in the same way as the MonsterInsights plugin does.

Test curl from terminal

curl -v https://www.google.com

If curl is working, you should see a bunch of text like this:

2023 12 13 09 46 - MonsterInsights - The firewall of your server is blocking outbound calls. Please contact your hosting provider to fix this issue.

But if it is not, and for example you receive any of these errors:

Error CodeDescription
6Could not resolve host
7Failed to connect to host
28Operation timed out
35SSL connect error
47Maximum redirects reached
60SSL certificate problem
77Error reading ca cert file
78Error writing to socket
52Empty reply from server
51SSL peer certificate status does not match

Then contact your hosting provider immediately so that they can check for ongoing DDoS attacks or network problems.


Edit MonsterInsights code to bypass the check

If curl is working, then the check in plugin code is failing and you can bypass it by editing the file wp-content/plugins/google-analytics-for-wordpress/includes/api-request.php and in it comment our the code for the check:

2023 12 13 10 49 - MonsterInsights - The firewall of your server is blocking outbound calls. Please contact your hosting provider to fix this issue.

Replace:

	public function request( $extra_params = [] ) {
		// Make sure we're not blocked
		$blocked = $this->is_blocked( $this->url );
		if ( $blocked || is_wp_error( $blocked ) ) {
			if ( is_wp_error( $blocked ) ) {
				// Translators: Placeholder gets replaced with the error message.
				return new WP_Error( 'api-error', sprintf( __( 'The firewall of your server is blocking outbound calls. Please contact your hosting provider to fix this issue. %s', 'google-analytics-for-wordpress' ), $blocked->get_error_message() ) );
			} else {
				return new WP_Error( 'api-error', __( 'The firewall of your server is blocking outbound calls. Please contact your hosting provider to fix this issue.', 'google-analytics-for-wordpress' ) );
			}
		}

with:

	public function request( $extra_params = [] ) {
		// Make sure we're not blocked
/*		$blocked = $this->is_blocked( $this->url );
		if ( $blocked || is_wp_error( $blocked ) ) {
			if ( is_wp_error( $blocked ) ) {
				// Translators: Placeholder gets replaced with the error message.
				return new WP_Error( 'api-error', sprintf( __( 'The firewall of your server is blocking outbound calls. Please contact your hosting provider to fix this issue. %s', 'google-analytics-for-wordpress' ), $blocked->get_error_message() ) );
			} else {
				return new WP_Error( 'api-error', __( 'The firewall of your server is blocking outbound calls. Please contact your hosting provider to fix this issue.', 'google-analytics-for-wordpress' ) );
			}
		}
*/

Just add /* bfore the code and */ after it to comment it out.

Then save the file and navigate back to the plugins page where you will see a prompt to reconnect your GoogleAnalytics account. After you do so, the plugin should work:

2023 12 13 10 54 1024x509 - MonsterInsights - The firewall of your server is blocking outbound calls. Please contact your hosting provider to fix this issue.

Was this post helpful?

Leave a Comment

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.

Recommended