Error reading service account token from /var/run/secrets/kubernetes.io/serviceaccount/token. Ignoring
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
The warning Error reading service account token from /var/run/secrets/kubernetes.io/serviceaccount/token. Ignoring appears when an application running inside a Kubernetes pod tries to read the automatically mounted service account token but fails. This is common when running applications locally outside of Kubernetes, or when the service account token volume has been explicitly disabled.
Why This Happens
By default, Kubernetes mounts a service account token into every pod at the path /var/run/secrets/kubernetes.io/serviceaccount/. This token allows the pod to authenticate with the Kubernetes API server. The error occurs when:
1. Running Outside Kubernetes
If you run your application locally (e.g., during development), the path /var/run/secrets/kubernetes.io/serviceaccount/token does not exist. Libraries like the Kubernetes client for Python, Java, or Go automatically attempt to detect if they are running in-cluster by reading this token:
2. Service Account Token Mounting Disabled
Starting with Kubernetes 1.24, you can disable automatic token mounting:
Or at the ServiceAccount level:
3. Token Volume Not Yet Mounted
In rare cases, the kubelet has not yet mounted the projected volume when the application starts. This is a timing issue that typically resolves on its own.
4. Incorrect Permissions
The token file exists but the container process does not have read permissions:
How to Fix It
If Running Locally (Not in Kubernetes)
This warning is expected and can safely be ignored. Ensure your application falls back to local configuration:
If Running in Kubernetes and Token is Needed
Verify the service account token is mounted:
Ensure automountServiceAccountToken is not set to false:
If You Do Not Need Kubernetes API Access
If your application does not need to talk to the Kubernetes API, you can safely suppress the warning. Disable token mounting to reduce the attack surface:
Bound Service Account Tokens (Kubernetes 1.22+)
Modern Kubernetes versions use bound service account tokens with automatic rotation. Instead of a static secret, a projected volume provides a time-limited, audience-bound token:
If you see token read errors with bound tokens, the token may have expired. The kubelet should rotate it automatically, but check kubelet logs if this persists.
Common Pitfalls
- Treating the warning as an error: In most cases this is informational, not fatal. Applications that do not need the Kubernetes API should simply log and continue.
- Hardcoding the token path: Always use the official client libraries rather than reading the token file directly. The libraries handle fallback and rotation.
- Security implications of leaving tokens mounted: Unused service account tokens increase the blast radius of a container compromise. Disable mounting when the pod does not need API access.
- RBAC issues masked by this error: If the token exists but RBAC denies access, you will see a different error (403 Forbidden). Do not confuse the two.
Summary
- This warning means the service account token file cannot be read at the expected path
- When running locally, it is expected — ensure your code falls back to kubeconfig
- When running in Kubernetes, verify
automountServiceAccountTokenis not disabled - For pods that do not need API access, disable token mounting to improve security
Related reading
- Error UPGRADE FAILED binder has no deployed releases
- Error UPGRADE FAILED error validating error validating data ValidationErrorIngress.spec.rules0.http missing required field paths
- error when creating deployment.yaml Deployment in version v1 cannot be handled as a Deployment
- Essential container in task exited
- Error response from daemon Get https//ghcr.io/v2/ denied denied
- Error response from daemon No build stage in current context
- Error when trying to obtain a certificate The specified item could not be found in the keychain
- Example code for AWS Cognito User Pool InitiateAuth with Username and Password via HTTPS call?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.