wget encounter error "Error parsing proxy URL xxx Unsupported scheme 'socks5'"

VPN

Image credit: Unsplash

In my .bashrc, i configure the proxy like this

export http=http://127.0.0.1:8000
export https=http://127.0.0.1:8000

export http_proxy=socks5://127.0.0.1:1080
export https_proxy=socks5://127.0.0.1:1080

export ALL_PROXY=socks5://127.0.0.1:1080

and when i use wget to download some file, i encounter this error:

Error parsing proxy URL socks5://127.0.0.1:1080: Unsupported scheme ‘socks5’.

Actually i don’t know the reason behind this, but i find one solution that can solve this problem

Solution-tsocks

we can use a tscocks to make wget use proxy

  1. install tsocks

    arch linux:

    sudo pacman -S tsocks
    

    ubuntu:

    sudo apt install tsocks
    
  2. modifty configure file of tsocks

    my /etc/tsocks.conf doesn’t exist, so we need copy file from /usr/share/tsocks/tsocks.conf.simple.example

    sudo cp /usr/share/tsocks/tsocks.conf.simple.example /etc/tsocks.conf 
    

    modify the content of /etc/tsocks.conf as follows

    # This is the configuration for libtsocks (transparent socks)
    # Lines beginning with # and blank lines are ignored
    #
    # This sample configuration shows the simplest (and most common) use of
    # tsocks. This is a basic LAN, this machine can access anything on the
    # local ethernet (192.168.0.*) but anything else has to use the SOCKS version
    # 4 server on the firewall. Further details can be found in the man pages,
    # tsocks(8) and tsocks.conf(5) and a more complex example is presented in
    # tsocks.conf.complex.example
    
    # We can access 192.168.0.* directly
    # local = 192.168.0.0/255.255.255.0
    
    # Otherwise we use the server
    server = 127.0.0.1
    # Server type defaults to 4 so we need to specify it as 5 for this one
    server_type = 5
    # The port defaults to 1080 but I've stated it here for clarity 
    server_port = 1080
    
  3. unset your proxy environment variable

    unset https_proxy
    
  4. add tsocks before wget

    tsocks wget ...
    

Done~~

Reference

  1. linux shell走socks5代理

  2. wget socks5 代理

  3. wget:不支持的协议类型 “socks5”

QianLong Sang
QianLong Sang
Second Year CS Phd

My research interests include operating system, computer architecture and computer security.