Skip to content
Latchkey

GitHub Actions docker/login-action "Username and password required"

docker/login-action needs both a username and a password (or token). When a referenced secret is empty or misnamed, the action receives a blank value and refuses to attempt the login.

What this error means

A docker/login-action step fails immediately stating that a username and password are required, before contacting the registry.

github-actions
Error: Username and password required

Common causes

Secret unset or misnamed

A password mapped to a secret that does not exist resolves to an empty string, which the action rejects.

Secret not available to the context

Secrets are not passed to workflows triggered by forked pull_request events, so the value is empty there.

How to fix it

Supply non-empty credentials

  1. Confirm the secret name matches exactly and the secret has a value.
  2. For GHCR, use github.actor and secrets.GITHUB_TOKEN.
  3. Skip or gate the login on forked PRs where secrets are unavailable.
.github/workflows/ci.yml
- uses: docker/login-action@v3
  with:
    registry: docker.io
    username: ${{ secrets.DOCKERHUB_USERNAME }}
    password: ${{ secrets.DOCKERHUB_TOKEN }}

How to prevent it

  • Double-check secret names against repository/organization settings.
  • Guard registry login steps so forked PRs without secrets do not run them.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →