Search code examples
pythondjangoweb-deploymentcloudinarypythonanywhere

Uploaded an image got [Error 111] using Cloudinary on Pythonanywhere


I'm using Pythonanywhere to store my Django code and everything run properly except when I'm trying to upload an image.

I got this error:

cloudinary.exceptions.Error: Unexpected error - MaxRetryError("HTTPSConnectionPool(host='api.cloudinary.com', port=443): Max retries exceeded with url: /v1_1/MY-CLOUD-NAME/image/upload (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f5de5f6e6d0>: Failed to establish a new connection: [Errno 111] Connection refused'))")

This is my code in model.py:

from cloudinary.models import CloudinaryField

some class
    project_image = CloudinaryField("project_img", proxy="http://proxy.server:3128")

This is my code in setting.py:

CLOUDINARY = {
  'cloud_name': 'CLOUD-NAME',  
  'api_key': 'xx',  
  'api_secret': 'xx,
}

CLOUDINARY_URL='cloudinary://xxx@CLOUD-NAME?api_proxy=proxy.server:3128'

I also tried to change the proxy.server part to:

- https://api.cloudinary.com/v1_1/MY-CLOUD-NAME

and add the api_proxy in CLOUDINARY parameter but It didn't work also

P.S. I'm using a free Pythonanywhere account and I do some research and the owner said that I have to set the proxy to proxy.server:3128 but I don't know how to do that

P.S.2 What I've tried to do so far

  • upgrade urllib but didn't work out

  • try to add a proxy in many different ways on setting.py as you saw above


Solution

  • Is your settings try setting the api as follows:

    CLOUDINARY = {
      'cloud_name': 'CLOUD-NAME',  
      'api_key': 'xx',  
      'api_secret': 'xx',
      'api_proxy': 'http://proxy.server:3128'
    }
    

    As referred in this github issue comment.