Fix Python – Using pip behind a proxy with CNTLM


Asked By – serverpunk

I am trying to use pip behind a proxy at work.

One of the answers from this post suggested using CNTLM. I installed and configured it per this other post, but running cntlm.exe -c cntlm.ini -I -M gave the error Connection to proxy failed, bailing out.

I also tried pip install -–proxy=user:pass@localhost:3128 (the default CNTLM port) but that raised Cannot fetch index base URL Clearly something’s up with the proxy.

Does anyone know how to check more definitively whether CNTLM is set up right, or if there’s another way around this altogether? I know you can also set the http_proxy environment variable as described here but I’m not sure what credentials to put in. The ones from cntlm.ini?

Now we will see solution for issue: Using pip behind a proxy with CNTLM


To setup CNTLM for windows, follow this article. For Ubuntu, read my blog post.


Basically, to use CNTLM in any platform, you need to setup your username and hashed password, before using as a proxy to your parent proxy.

  1. Edit the config and add important information like domain, username, password and parent proxy.

  2. Generate hashed password.

    Windows cntlm –c cntlm.ini –H

    Ubuntu/Linux cntlm -v -H -c /etc/cntlm.conf

  3. Remove plain text password from the config and replace them with the generated passwords.

To check if working:

Windows cntlm –M

Ubuntu/Linux sudo cntlm -M

For more detailed instructions, see links above.


Just for completeness sake, I was able to configure and use CNTLM in Windows recently. I encountered a problem during the syncing process of Kindle for PC because of our proxy and installing and configuring CNTLM for Windows fixed that issue for me. Refer to my article for more details.

This question is answered By – Annie Lagang

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0