Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
I receive this error when I introduce the API key froom my mailchimp account in mailchimp module configuration page. ---> Could not connect to Mailchimp
in watchdog the details says: MCAPI Error: Could not connect to Mailchimp
In my local version of the site it does not happen, so it looks like a server problem, but how can I be sure of that? Any suggestions?¿ Anyone with the same problem??
Thanks!
Comment | File | Size | Author |
---|---|---|---|
#7 | MCAPI.class_.txt | 141.85 KB | realrudymartin |
Comments
Comment #1
bleedev CreditAttribution: bleedev commentedThe error should only be logged when the service cannot be reached. Were the MailChimp lists available after the API key was input?
Comment #2
jordiserra CreditAttribution: jordiserra commentedNo, I don't have any lists available after this error. I think it should be a problem with the server, maybe a closed port which is necessary to reach mailchimp. I am waiting the response from the technical service......
Comment #3
patrick.davey CreditAttribution: patrick.davey commentedDid you ever get past this? I've just updated from 2.5 to 2.6 and now cannot connect.
Could roll back, but have strange behaviour with user settings not sticking until Cron is run.
Comment #4
sugarbase CreditAttribution: sugarbase commentedI get the same error on both local & a live site.
All I see when in settings is 1 field for the API key, which when I enter it I get the following messages,
I have tried this on a fresh install of drupal with no other modules too with the same results.
The mailchimp account does have a list created. Or should I be creating a list within Drupal?
Apologies if I am doing something simple wrong, but I have never used mailchimp before & can't find a solution anywhere.
Thanks.
Comment #5
sugarbase CreditAttribution: sugarbase commentedTurns out it was the server firewall blocking the connection to the mailchimp API.
I assumed I was doing something incorrect as it wasn't working on my local server either, and as I had never used the module before I didn't know if it wasn't working due to user error (i.e. Me). But when I tested it on a different live server it worked fine.
In case others come across the same issue here are the domains you need to allow in your firewall rules.
us1.api.mailchimp.com
us2.api.mailchimp.com
You will probably need the actual ip addresses to add them to your firewall rules, so ping the above urls and you will get the current ip address. The IP addresses may change from time to time, so if the connection fails after a sucessful installation ping them again and get the new ip address.
Comment #6
bleedev CreditAttribution: bleedev commented@sugarbase Thanks for the update.
Comment #7
realrudymartin CreditAttribution: realrudymartin commentedI replaced the MCAPI.class.php file in the Drupal 6.2 versions with the latest one from Drupal 7 and it works. Rename the attached text file to php and use it.
Comment #8
rpcvron CreditAttribution: rpcvron commentedreplacing the MCAPI.class.php file with the 7.x version (post #7), also fixed the issue for me
Comment #9
Hammad.Chishti CreditAttribution: Hammad.Chishti commentedI replaced the file but mailchimp stop fetching list from mailchimp website, couldnt understand why.
Still getting "could not connect to mailchimp".
Please help me
thanks
Comment #10
Hammad.Chishti CreditAttribution: Hammad.Chishti commentedThis will be solve by editing mailchimp 1.2v, there is a mistake in MCAPI class file,
if ($this->secure){
try {
$sock = @fsockopen("ssl://".$host, 443, $errno, $errstr, 30);
if(!$sock){
throw new Exception('Could not connect to Mailchimp');}
} catch (Exception $e) {
drupal_set_message($e->getMessage(), 'warning', $repeat=false);
watchdog('mailchimp', 'MCAPI Error: %errormsg', array('%errormsg' => $e->getMessage()), WATCHDOG_ERROR);
}
} else {
try {
$sock = @fsockopen("ssl://".$host, 443, $errno, $errstr, 30); // This is the mistake which calling ssl in both if and else, fix by replacing following line //
$sock = @fsockopen($host, 80, $errno, $errstr, 30);
if(!$sock){
throw new Exception('Could not connect to Mailchimp');}
} catch (Exception $e) {
drupal_set_message($e->getMessage(), 'warning', $repeat=false);
watchdog('mailchimp', 'MCAPI Error: %errormsg', array('%errormsg' => $e->getMessage()), WATCHDOG_ERROR);
}
}
Comment #11
kemmett CreditAttribution: kemmett commentedThanks Hammad, your solution worked for me (MailChimp module 6.x-2.6)
Chris
Comment #12
NancyDruIf there is an error in the class file, then how can we say "works as designed?" The error needs to be fixed and a new release rolled out.
And, yes, pulling down the 7.x class file seems to get me farther along.
Comment #13
NancyDruComment #14
bentekwork CreditAttribution: bentekwork commentedI had a similar issue with Mailchimp not working on a local MAMP installation. I was able to narrow the issue down to mailchimp.inc. This is where the MCAPI class is being extended and the callServer method is being overridden. It is using drupal_http_request to return the response. Where as MCAPI is using fsockopen. I was able to solve my issue by deleting the entire mailchimp.inc file. And replacing line 201 in mailchimp.module.
Replace this:
With this:
Comment #15
TJ43 CreditAttribution: TJ43 commentedI applied the patch suggested in #14 above to a Drupal 7.19, MailChimp 7.x-2.9, MCAPI 1.3 install running on LAMP and the existing lists are now available. This is a working site that is being upgraded from Drupal 6.9 and MailChimp 6.x-2.4. FWIW the MailChimp account API key was-and-is on data center us2.
Comment #16
levelos CreditAttribution: levelos commentedFolks, this thread is completely unfocused and touching on different versions of the module and different issues. If there is a specific issue with an specific version of the module, lets discuss and resolve. The 6.x and 7.x have a completely different feature set, code base, and architecture, so please don't mingle issues across them. @bentekwork, your idea is completely bypassing the module design. If you can't connect, the goal should be figure out why.
This thread started with some folks on 6.x having issues connecting to the MCAPI. I'm going to close this, but if that's still an active issue, then consider reopening with specifics. In general, we're not maintaining the 6.x version any longer and only applying critical bugs or security patches.