Here HomeBrew installation does not work behind proxy and one has to avoid that using the following command in terminal:
export ALL_PROXY=$http_proxy:port
or export ALL_PROXY=proxy ip address : port number (do not give spaces ) After
export ALL_PROXY=proxy ip address:port number # do not give spaces
After this is done, installation worked smoothly.