apt-get returns 404 Not Found while building an old Debian-based image
404 Not Found while running apt-get update on a jessie imageShort answer
Debian Jessie reached end of life in 2018 and its packages now live only on archive.debian.org. An old base image such as Node 8 on Jessie still points at the normal mirrors, so apt gets 404. The proper fix is a supported base image; the stopgap is to point apt at the archive.
Fix it fast
1Find out which cause you have
Find out which Debian release the base image is built on. If it says jessie, the repositories your image points at no longer carry it.
docker run --rm my-base-image cat /etc/os-release docker run --rm my-base-image cat /etc/apt/sources.list2Match what you see, then jump to its fix
- 1
os-release shows jessie (Debian 8) and the 404 URLs contain /dists/jessieThe base image is an end-of-life release that the main mirrors droppedFix - 2
You must keep the old image for now, and the 404 lines show deb.debian.org or security.debian.orgYou cannot upgrade yet: apt must point at the Debian archiveFix - 3
apt reports that the Release file for the jessie archive has expiredapt rejects the archive's Release file as expiredFix
- 1
What does the error look like?
404 Not Found while running apt-get update on a jessie imageE: Failed to fetch ... dists/jessie ... 404 Not Found
Cause 1 of 3
The base image is an end-of-life release that the main mirrors dropped
1Check
Debian Jessie reached end of life on 2018-06-17 and, like stretch and buster, is kept only in the archive. Node.js 8 is also end of life, so the old node:8-jessie tag is not a base to keep.
grep FROM Dockerfile2Fix
Move to a supported base image and a supported Node.js line, then fix whatever your app needs to run there.
# Dockerfile
FROM node:243Verify
The build runs apt-get without any 404.
docker build --no-cache -t my-app .Confirmed by debian.org
Cause 2 of 3
You cannot upgrade yet: apt must point at the Debian archive
1Check
Old releases are available from archive.debian.org under dists/jessie. The sources.list in the image still names the regular mirrors.
docker run --rm my-base-image cat /etc/apt/sources.list2Fix
Replace the sources with the archive. This is a temporary bridge for a build you cannot change yet; the image gets no security updates.
RUN echo 'deb http://archive.debian.org/debian jessie main' > /etc/apt/sources.list \
&& apt-get update3Verify
apt-get update finishes without a 404 (see the next cause if it complains about an expired Release file).
docker build --no-cache -t my-app .Confirmed by debian.org
Cause 3 of 3
apt rejects the archive's Release file as expired
1Check
apt checks the Valid-Until date of the Release file by default, and an archived release no longer gets new Release files, so the date in the old one is in the past.
docker run --rm my-base-image apt-get update2Fix
Turn the check off for that one source entry, which is what the apt documentation prefers over disabling it globally.
RUN echo 'deb [check-valid-until=no] http://archive.debian.org/debian jessie main' > /etc/apt/sources.list \
&& apt-get update3Verify
apt-get update completes.
docker build --no-cache -t my-app .Confirmed by manpages.debian.org
How do I stop it coming back?
- Do not build on a distribution release that has reached end of life; check its dates on the Debian releases page before choosing a tag.
- Pin the base image to a supported Node.js version, for example node:24, and name the Debian release with a tag such as bookworm or trixie when it matters.
- Put a rebuild of the image in CI so a vanished mirror is found on a Tuesday, not during a production deploy.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
Related fixes
Servers
ng serve runs in the container but localhost:4200 does not open
The browser cannot open localhost:4200 although ng serve is running in the container
ng serve listens on localhost by default, which inside a container is the container itself.
3 causes, each with a fixServers
bcrypt_lib.node: invalid ELF header inside a Docker container
Error: /app/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header
bcrypt is a compiled addon, so the file in node_modules only runs on the operating system it was installed on.
3 causes, each with a fixServers
cdk deploy fails in a GitLab job with spawnSync docker ENOENT
code: 'ENOENT'
ENOENT means the operating system found no docker program to run.
3 causes, each with a fixServers
Cypress says the npm package is installed but the binary is missing
Cypress binary is missing after npm install in CI or in a Docker build
The npm package is only a launcher.
3 causes, each with a fixServers
Node.js app says Cannot find module only when it runs under Docker Compose
The same image starts fine with docker run but fails with docker compose up
The image installed node_modules, but a Compose volume mounted over the app folder hides them.
3 causes, each with a fixServers
EACCES permission denied when a container creates node_modules/.cache
The dev server exits right after start when node_modules is a Compose volume
The container user cannot write inside node_modules because the folder is owned by root.
2 causes, each with a fix