Error connecting to Mailchimp: 503 Service Unavailable
-
I am getting an error 503 Service Unavailable even after purchasing a dedicated IP. I have generated the API 3 times. The same API works on local installation of wordpress ( php 7.4, apache).
I communicated with Mail Chimp and they confirmed the domain is not blocked and everything is ok from their end.
The hosting company says it will resolve itself!!
I have changed to php8.2 on the live site and checked if cUrl is installed and i get it enabled and version 8.1.2 .
But i still get the same error.- This topic was modified 1 year, 4 months ago by jkkenzie.
-
It seems your hosting server IP is blocked by the MailChimp firewall. When you are on shared hosting you share the IP address with a number of other websites on the same server. It is possible that someone else did something (bad) to get the shared IP on the blocked list.
Akamai is the firewall service MailChimp uses to protect their servers, which is why this is somewhat harder to fix. We recommend you to change your IP address because having a bad reputation at Akamai does not just affect the MailChimp API, but several other websites as well.
There are various ways to fix this:
- Ask your webhost for a new IP address.
- Migrate to a new webhost if your hosting company is unwilling to fulfill your request.
- Configure your server to connect to the MailChimp API server using a proxy.
Hope that helps. If you have any questions, please let us know!
What you are saying made me purchase a Dedicated IP. Once the new IP was made, i tested and it failed – so its not the IP.
Is there a hook in the plugin i can get a complete cURL error information? Instead of just 503 Service Unavailable.
Maybe cURL itself has more details.
Also am seeing some errors on php 8.1, i dont know if they are related:
Undefined variable $data in /mailchimp-for-wp/includes/class-mailchimp.php on line 434
and
Attempt to read property “total_items” on null in /home1/lubez1ne/public_html/wp-content/plugins/mailchimp-for-wp/includes/class-mailchimp.php on line 434- This reply was modified 1 year, 4 months ago by jkkenzie.
If you have SSH access to your hosting server, you can execute cURL from the terminal manually like this:
cURL https://us1.api.mailchimp.com/3.0/?apikey=YOUR KEY HERE
But replace us1 with your Mailchimp server (last part of your API key, and add your API key to the end instead of YOUR KEY HERE
We’ve seen situations where cURL over SSH would use a different IP from cURL via PHP though. We’ve also seen situations where the host had set up the dedicated IP only for inbound connections and cURL was still routed over the shared IP for outgoing connections.
I don’t think the PHP notice is related to this but if your host has a simple way to temporarily switch to another PHP version it’s worth a try to see if it makes any difference.I have switched between php 7.4, 8.0, 8.1 and 8.2 and same problem.
I was ale to get this cURL response:Using the php code below and got the log below it:
function custom_http_api_debug($response, $r, $url) { if (is_wp_error($response)) { $error_message = $response->get_error_message(); error_log("cURL Error: " . $error_message); } else{ $response_string = print_r($response, true); error_log("cURL test: ".$response_string); } return $response; } add_action('http_api_debug', 'custom_http_api_debug', 10, 5);
[12-Jul-2023 07:22:23 UTC] cURL test: Array ( [headers] => WpOrg\Requests\Utility\CaseInsensitiveDictionary Object ( [data:protected] => Array ( [server] => AkamaiNetStorage [content-length] => 125 [content-type] => application/json [etag] => "953d389c654d003dd7a67b8f959df97a:1452000673" [cache-control] => max-age=34887 [date] => Wed, 12 Jul 2023 07:22:23 GMT ) ) [body] => {"type":"akamai_error_message","title":"akamai_503","status":503,"ref_no":"Reference Number: 00.53680117.1689146543.9b7b00d"} [response] => Array ( [code] => 503 [message] => Service Unavailable ) [cookies] => Array ( ) [filename] => [http_response] => WP_HTTP_Requests_Response Object ( [response:protected] => WpOrg\Requests\Response Object ( [body] => {"type":"akamai_error_message","title":"akamai_503","status":503,"ref_no":"Reference Number: 00.53680117.1689146543.9b7b00d"} [raw] => HTTP/1.1 503 Service Unavailable Server: AkamaiNetStorage Content-Length: 125 Content-Type: application/json ETag: "953d389c654d003dd7a67b8f959df97a:1452000673" Cache-Control: max-age=34887 Date: Wed, 12 Jul 2023 07:22:23 GMT Connection: close {"type":"akamai_error_message","title":"akamai_503","status":503,"ref_no":"Reference Number: 00.53680117.1689146543.9b7b00d"} [headers] => WpOrg\Requests\Response\Headers Object ( [data:protected] => Array ( [server] => Array ( [0] => AkamaiNetStorage ) [content-length] => Array ( [0] => 125 ) [content-type] => Array ( [0] => application/json ) [etag] => Array ( [0] => "953d389c654d003dd7a67b8f959df97a:1452000673" ) [cache-control] => Array ( [0] => max-age=34887 ) [date] => Array ( [0] => Wed, 12 Jul 2023 07:22:23 GMT ) ) ) [status_code] => 503 [protocol_version] => 1.1 [success] => [redirects] => 0 [url] => https://us17.api.mailchimp.com/3.0/?fields=account_id [history] => Array ( ) [cookies] => WpOrg\Requests\Cookie\Jar Object ( [cookies:protected] => Array ( ) ) ) [filename:protected] => [data] => [headers] => [status] => ) )
As you can see in the cURL response, the IP being used for outbound cURL calls is blocked by Akamai.
{“type”:”akamai_error_message”,”title”:”akamai_503″,”status”:503,”ref_no”:”Reference Number: 00.53680117.1689146543.9b7b00d”}
You can give that reference number to Mailchimp support if you like them to look it up.
You can run cURL https://icanhazip.com/ to see what the outbound IP address is for those cURL calls if you want to confirm it’s actually using your dedicated IP.
Hope that helps. If you have any questions, please let me know!i did another php function:
function make_mailchimp_api_request() { // Mailchimp API endpoint $api_url = 'https://YOUR_SUBDOMAIN.api.mailchimp.com/3.0/?apikey=YOUR_API_KEY'; // Initialize cURL session $ch = curl_init(); // Set cURL options curl_setopt($ch, CURLOPT_URL, $api_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Execute the request $response = curl_exec($ch); // Log the response error_log('Mailchimp API Response: ' . $response); // Check for cURL errors if (curl_errno($ch)) { $error_message = curl_error($ch); // Handle the error accordingly } // Close the cURL session curl_close($ch); // Return the response return $response; } add_action('http_api_debug', 'make_mailchimp_api_request', 10, 5);
and got the API response:[12-Jul-2023 10:53:55 UTC] Mailchimp API Response: {"type":"akamai_error_message","title":"akamai_503","status":503,"ref_no":"Reference Number: 00.53680117.1689159235.b510dec"} [12-Jul-2023 10:53:56 UTC] Mailchimp API Response: {"type":"akamai_error_message","title":"akamai_503","status":503,"ref_no":"Reference Number: 00.53680117.1689159236.b511531"}
As you can see the response from the Mailchimp API is that the IP is blocked by the Akamai firewall that they use.
You can give that reference number to Mailchimp support if you like them to look it up.
You can run cURL https://icanhazip.com/ to see what the outbound IP address is for those cURL calls if you want to confirm it’s actually using your dedicated IP.
Hope that helps. If you have any questions, please let me know!
I tested the URL you gave me and it gave me an IP not the same as the dedicated IP i bought….
So you are right! Thanksfunction make_mailchimp_api_request() { $api_url = 'https://icanhazip.com/'; // Initialize cURL session $ch = curl_init(); // Set cURL options curl_setopt($ch, CURLOPT_URL, $api_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Execute the request $response = curl_exec($ch); // Log the response error_log('Mailchimp API Response: ' . $response); // Check for cURL errors if (curl_errno($ch)) { $error_message = curl_error($ch); // Handle the error accordingly } // Close the cURL session curl_close($ch); // Return the response return $response; } add_action('http_api_debug', 'make_mailchimp_api_request', 10, 5);
- The topic ‘Error connecting to Mailchimp: 503 Service Unavailable’ is closed to new replies.