Recently I came accross the issue of wanting to install apt packages in WSL behind a corporate proxy. Plus I wanted to update my yarn package by using “curl -o- -L | bash” which also needs to go through the proxy.

The solution is the same as if we want to set the proxy in a standard Ubuntu. So simply create a proxy.conf inside the apt config folder as follows.

vi /etc/apt/apt.conf.d/proxy.conf
# add the following line (press i to insert and escape followed by :x to save)
Acquire::http::Proxy "http://username:password@myproxy:myproxyport";

Aditionally we need to set the proxy for curl. For that we create or modify an user specific ~/.curlrc file in our homefolder.

cd ~/
vi .curlrc
# insert the following line
proxy = <proxy_host>:<proxy_port>

Thats it. You are now using apt and curl through your corporate proxy.


Eric · 29. September 2020 at 21:40

dumb question but in the proxy for curl do we need to include the brackets?

    Michael · 30. September 2020 at 6:48

    No you simply put it in the host and port, like this:


Linus · 11. March 2021 at 10:10

What about special characters in the password?

    Michael · 16. March 2021 at 7:39

    You can url encode them, E.g.: \ becomes %5C

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: