'Could not handshake' : Error while doing sudo apt-get update

Ashj picture Ashj · May 19, 2019 · Viewed 8.5k times · Source

I am trying to install QGIS 3.4 on my Ubuntu 18.04. I am following instructions given at QGIS website.

I have also updated my /etc/apt/sources.list file as below.

deb https://qgis.org/ubuntu-ltr bionic main
deb-src https://qgis.org/ubuntu-ltr bionic main

While doing 'sudo apt-get update' I'm getting the below error.

ashj@ashj:~/Downloads/LAStools$ sudo apt-get update
[sudo] password for ashj: 
Ign:1 https://qgis.org/ubuntu-ltr bionic InRelease
Err:2 https://qgis.org/ubuntu-ltr bionic Release                                                                
  Could not handshake: An unexpected TLS packet was received. [IP: 10.4.21.120 8080]

I have searched for this error and tried this post and made respective updates. Yet I am not able to resolve it.

Could anyone help me understand what might be going wrong?

Answer

G_Style picture G_Style · Mar 3, 2021

In case someone comes here wondering why their proxy isn't handshaking for apt updates... This happens because sometimes APT will not obey environment variables. In that case (as some others have commented), create a new file for apt to process like so:

nano /etc/apt/apt.conf.d/95proxies

and then add these lines (one for http and https) with your proxy server address and port:

Acquire::http::proxy "http://xxx.xxx.xxx.xxx:8080";
Acquire::https::proxy "http://xxx.xxx.xxx.xxx:8080";

Save the file. An apt update should work as soon as its there but you may want to reboot for good measure.