Forums

Configure proxy for cloudinary

Can I kindly get an example of how to configure proxy so that I can use cloudinary

Could you give a few more details about what you mean? Do you want to access Cloudinary's API, but can't access it from your free account? I think all of their stuff is whitelisted.

Yes. I can't access it because I have a free account. So I would like to know how to set up the proxy (From solutions to the errors am getting it is required that I configure proxy which I don't know how to). It is said that even if it is whitelisted, I need to configure a proxy if I have a free account.

Ah, I see. Most modern APIs don't need to be specially configured to use a proxy -- they'll pick it up from the environment. Do you get errors when you try to use it without any specific proxy configuration?

Yeah. Initially, I had not configured any proxy and I was getting the error.

What error was it? Was it a 403 forbidden error? Or a Connection refused? Or something else?

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

Hmm, interesting. That indicates that the code is not trying to use the proxy, but urllib3 has been proxy-aware for some time.

Could you try upgrading urllib3? To do that, run

pip3.6 install --user --upgrade urllib3

...in a bash console (replacing the 3.6 with the Python version you're using if it's a different one).

Just ran that but still getting the same error. Here is the complete error: https://jsfiddle.net/rfybgj8k/1/

It looks like the cloudinary library does not recognise the proxy settings. There may be a way to configure it to use a proxy - you'll have to check their documentation for that. Otherwise, the lack of proxy support may be something you can raise with the authors of the cloudinary library.

I was facing the same issue and it was resolved by writing this exact same code snippet.

import cloudinary
cloudinary.config(
  cloud_name = config('CLOUD_NAME'),
  api_key = config('CLOUD_API_KEY'),
  api_secret = config('CLOUD_API_SECRET'),
  api_proxy = "http://proxy.server:3128"
)
import cloudinary.uploader
import cloudinary.api

Thanks for letting us know!

Works for me too. Thanks

Works for me too. Thanks a lot.

Glad to hear that!

Thanks man

i dont know hw to create an api_proxy i need help

You don't need to create it. Here's some info on the PythonAnywhere proxy