Connection Refused while apt-get update ubuntu 18.04 over proxy

The issue is that the proxy settings are not being passed to the "sudo" level. You are able to ping and wget stuff as a normal user since you have the http_proxy and https_proxy settings set for that current user. When you use sudo, those environment variables are not passed to the elevated user.

The solution is to use -E with sudo to pass on those environment variables to the elevated user.

For example, do the following:

sudo -E apt-get update

It should work.