Linux : apt-get Failed to fetch FailReason: ConnectionRefused

By | July 26, 2019

Experiencing the following issue trying to update your Debian distro using apt-get?

# apt-get update
Ign:1 http://deb.debian.org/debian stretch InRelease
Hit:2 http://deb.debian.org/debian stretch Release
Ign:3 http://repo.r1soft.com/apt stable InRelease
Hit:4 http://repo.r1soft.com/apt stable Release
Hit:5 http://security.debian.org/debian-security stretch/updates InRelease
Ign:8 https://download.webmin.com/download/repository sarge InRelease
Hit:9 https://download.webmin.com/download/repository sarge Release
Err:11 https://packages.sury.org/php stretch InRelease
FailReason: ConnectionRefused
Reading package lists… Done
W: Failed to fetch https://packages.sury.org/php/dists/stretch/InRelease FailReason: ConnectionRefused
W: Some index files failed to download. They have been ignored, or old ones used instead.

In that particular case, the pgp key was revoked/changed on that particular apt repo (packages.sury.org). To resolve this issue, you need to download the new key and import it as followed :

wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg

This should resolve the issue, you may issue the “apt-get update” command again to test.