Mailchimp issue production

the issue is it works fine locally and not on production i have teh same keys in local and production and also when i move config keys up and down on local the error generates on local as well for example if i put key in center it works and if i put on top or last it gives error. But in production it thorougly gives error

this is the error

An error occured due to : HTTPSConnectionPool(host='us-17.api.mailchimp.com', port=443): Max retries exceeded with url: /3.0/lists/5897c44639/members (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fd70a0e01f0>: Failed to establish a new connection: [Errno -2] Name or service not known'))

@api_view(['POST'])
@permission_classes([AllowAny])
def complete_reference(request, short_code):
    try:
        try:
            reference = Reference.objects.get(short_code = short_code)
        except:
            return Response({'status' : 400, 'message' : 'No reference found'})
        else:
            reference.dt_referred = timezone.now()

            message = request.data.get('message')
            if message:
                reference.message = message

            reference.save()

            i = intercom.intercom_reference_request_submitted(reference)
            try:
                mailchimp = MailchimpClient()

                list_id = settings.MAILCHIMP_AUDIENCE_LIST_ID
                response = mailchimp.add_to_list(
                    email=reference.email if reference.email else None,
                    phone=reference.phone if reference.email else None,
                    list_id=list_id,
                    tags=[get_campaign_tag(reference.email, reference.phone)]
                )
            except Exception as ex:
                raise Exception(ex)

            return Response({'status' : 200, 'message' : f"Reference saved {response['id']},   {response['status']}"})
    except Exception as ex:
        return Response({'status' : 400, 'message' : f"An error occured due to : {str(ex)}"})
    ```
Back to Top