Failed to update Linux headers on debian stretch / Debian 9
For
apt-get install linux-headers-$(uname -r)
to work, you need to be running a kernel which is still available from the distribution repositories; in most cases, this basically means you need to be running the latest supported kernel for your distribution.
On Debian, the simplest option is
apt-get update
apt-get install linux-image-amd64 linux-headers-amd64
(adjust to your architecture) to get the current kernel and matching headers, then reboot.
The linux-headers-4.9.0-3-amd64
is outdated , it is removed and replaced with the more recent package linux-headers-4.9.0-11-amd64
that's why you can't install it from the regular repository.
You can install the linux-headers-4.9.0-3-amd64
from the snapshot archive repository:
edit your sources list:
nano /etc/apt/sources.list.d/snapshot.list
Add the following lines:
deb http://snapshot.debian.org/archive/debian/20170609T034604Z stretch main
deb http://snapshot.debian.org/archive/debian/20170609T034604Z stretch-updates main
deb http://snapshot.debian.org/archive/debian-security/20170920T221221Z stretch/updates main
then:
apt -o Acquire::Check-Valid-Until=false update
apt install linux-headers-4.9.0-3-amd64
To access snapshots of suites using Valid-Until that are older than a dozen days, it is necessary to ignore the Valid-Until header within Release files, in order to prevent apt from disregarding snapshot entries ("Release file expired"). Use
aptitude -o Acquire::Check-Valid-Until=false update
orapt-get -o Acquire::Check-Valid-Until=false
update for this purpose.