Unable to run `apt update` on Ubuntu

When trying to update and upgrade Ubuntu, I kept getting “not longer has release file” or “404 Not Found.” I didn’t have VI or Nano, so I couldn’t edit any config files. I also didn’t have Net-tools, so I couldn’t troubleshoot the network, change my IP or DNS… or Gateway!! Really frustrating.

Get:1 https://download.docker.com/linux/ubuntu impish InRelease [48.9 kB]
Ign:2 http://archive.ubuntu.com/ubuntu impish InRelease
Ign:3 http://archive.ubuntu.com/ubuntu impish-updates InRelease
Ign:4 http://archive.ubuntu.com/ubuntu impish-backports InRelease
Ign:5 http://archive.ubuntu.com/ubuntu impish-security InRelease
Err:6 http://archive.ubuntu.com/ubuntu impish Release
  404  Not Found [IP: 91.189.91.39 80]
Err:7 http://archive.ubuntu.com/ubuntu impish-updates Release
  404  Not Found [IP: 91.189.91.39 80]
Err:8 http://archive.ubuntu.com/ubuntu impish-backports Release
  404  Not Found [IP: 91.189.91.39 80]
Err:9 http://archive.ubuntu.com/ubuntu impish-security Release
  404  Not Found [IP: 91.189.91.39 80]
Reading package lists... Done
E: The repository 'http://archive.ubuntu.com/ubuntu impish Release' no longer has a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://archive.ubuntu.com/ubuntu impish-updates Release' no longer has a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://archive.ubuntu.com/ubuntu impish-backports Release' no longer has a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://archive.ubuntu.com/ubuntu impish-security Release' no longer has a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
root@naboo:/# sudo apt install net-tools
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  net-tools
0 upgraded, 1 newly installed, 0 to remove and 28 not upgraded.
Need to get 193 kB of archives.
After this operation, 860 kB of additional disk space will be used.
Err:1 http://archive.ubuntu.com/ubuntu impish/main amd64 net-tools amd64 1.60+git20181103.0eebece-1ubuntu2
  404  Not Found [IP: 91.189.91.39 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/n/net-tools/net-tools_1.60%2bgit20181103.0eebece-1ubuntu2_amd64.deb  404  Not Found [IP: 91.189.91.39 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

Unfortunately, Impish went EoL on the 14th of July. As such, its repositories can no longer be found on the mirrors, so if you want to continue using this version, you need to use old-releases.ubuntu.com as your mirror. The caveat being that there will be no more upgrades for Impish, so you might want to switch to a supported version. The easiest way to upgrade is to run this command: do-release-upgrade

Luckily MikeF from the Server Fault website had a fix. MikeF writes that “the following two commands will update your APT sources to use the “old-releases” versions of the packages. After that, your “apt update” and “apt upgrade”` should succeed. Here are the commands: 

1. sudo sed -i -r 's/([a-z]{2}.)?archive.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list
2. sudo sed -i -r 's/security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list"