Instantly share code, notes, and snippets.

What would you like to do?
Proxy configuration by command line for some tools

Yarn configuration

$ yarn config set proxy http://username:password@host:port

$ yarn config set https-proxy http://username:password@host:port

NPM configuration

$ npm config set proxy http://username:password@host:port

$ npm config set https-proxy http://username:password@host:port

Or you can edit directly your ~/.npmrc file:




Remove configuration

npm config rm proxy

npm config rm https-proxy

Git configuration

git config --global http.proxy http://username:password@host:port

git config --global https.proxy http://username:password@host:port

Or you can edit directly your ~/.gitconfig file:

        proxy = http://username:password@host:port
        proxy = http://username:password@host:port

Bower configuration

Edit your ~/.bowerrc file:


Maven configuration

Edit the proxies session in your ~/.m2/settings.xml file


Maven Wrapper

Create a new file .mvn/jvm.config inside the project folder and set the properties accordingly:



Native Docker

Depending on your OS, you have to edit a specific file (/etc/sysconfig/docker or /etc/default/docker).

Then, restart the docker service with: sudo service docker restart.

It will not apply to systemd. See this page:

Docker with docker-machine

You can create your docker-machine with:

docker-machine create -d virtualbox \
    --engine-env HTTP_PROXY=http://username:password@host:port \
    --engine-env HTTPS_PROXY=http://username:password@host:port \

Or you can edit the file ~/.docker/machine/machines/default/config.json.


System-wide proxies in CLI Ubuntu/Server must be set as environment variables.

  1. Open the /etc/environment file with vi (or your favorite editor). This file stores the system-wide variables initialized upon boot.

Add the following lines, modifying appropriately. You must duplicate in both upper-case and lower-case because (unfortunately) some programs only look for one or the other:

  1. apt-get, aptitude, etc. will not obey the environment variables when used normally with sudo. So separately configure them; create a file called 95proxies in /etc/apt/apt.conf.d/, and include the following:
Acquire::http::proxy "";
Acquire::ftp::proxy "";
Acquire::https::proxy "";
  1. Verify that apt has picked up these settings via this command

apt-config dump | grep -i proxy # lists the proxy settings

Finally, logout and reboot to make sure the changes take effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment