unauthorized: authentication required 🐳 Docker

unauthorized: authentication required (docker push / pull)

The registry needs credentials for this operation and the request had none or had expired ones.

Seen on: Docker

Meaning

Docker sends credentials per registry host from ~/.docker/config.json (or a credential helper). If you logged in to docker.io but push to ghcr.io, or your token expired (ECR tokens last 12 hours, GitHub PATs can expire), the registry answers unauthorized.

Common causes

  • Not logged in to this registry host
  • Token/password expired or revoked
  • Credential helper failing silently
  • CI job missing the login step

⚡ Quick fix

  1. docker login <registry-host> again
  2. For GHCR use a PAT with read:packages/write:packages
  3. For ECR run aws ecr get-login-password

Detailed fix by platform

Docker

  1. echo $CR_PAT | docker login ghcr.io -u USERNAME --password-stdin

How to diagnose

  1. Host — Which registry is in the image name?
  2. Config — auths entry for that host?
  3. Token — Still valid and scoped?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.