question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Intermittent DefaultCredentialsError on GCE

See original GitHub issue

Original issue: https://github.com/GoogleCloudPlatform/google-cloud-python/issues/4358

After successful use of credentials, _ = google.auth.default(), an application crashes when credentials cannot be detected:

...
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/client.py", line 212, in __init__
    Client.__init__(self, credentials=credentials, _http=_http)
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/client.py", line 125, in __init__
    credentials, _ = google.auth.default()
  File "/usr/local/lib/python2.7/dist-packages/google/auth/_default.py", line 286, in default
    raise exceptions.DefaultCredentialsError(_HELP_MESSAGE)
DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or
explicitly create credential and re-run the application. For more
information, please see
https://developers.google.com/accounts/docs/application-default-credentials.

/cc @dmho418

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:23 (11 by maintainers)

github_iconTop GitHub Comments

12reactions
dhendrycommented, Oct 1, 2018

I would love to see a fix for this issue

2reactions
ghostcommented, Oct 26, 2019

I’m still seeing this error fairly regularly running on GAE flex for Python 3.6 with google-auth==1.6.3. Here’s the full stack trace:

  ...
  File "/env/lib/python3.6/site-packages/google/auth/transport/requests.py", line 205, in request
    self._auth_request, method, url, request_headers)
  File "/env/lib/python3.6/site-packages/google/auth/credentials.py", line 122, in before_request
    self.refresh(request)
  File "/env/lib/python3.6/site-packages/google/auth/compute_engine/credentials.py", line 102, in refresh
    six.raise_from(new_exc, caught_exc)
  File "<string>", line 3, in raise_from
google.auth.exceptions.RefreshError: HTTPConnectionPool(host='metadata.google.internal', port=80): Max retries exceeded with url: /computeMetadata/v1/instance/service-accounts/myst-ai-crystal@appspot.gserviceaccount.com/?recursive=true (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9964d74080>: Failed to establish a new connection: [Errno 111] Connection refused',))
Read more comments on GitHub >

github_iconTop Results From Across the Web

DefaultCredentialsError when trying to collect Google default ...
I am attempting to upload a file to a Google cloud storage bucket from a service running on a Kubernetes pod. This requires...
Read more >
Re: Could not automatically determine credentials.
DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create ...
Read more >
How Application Default Credentials works | Authentication
ADC searches for credentials in the following locations: GOOGLE_APPLICATION_CREDENTIALS environment variable; User credentials set up with the Google Cloud CLI ...
Read more >
DefaultCredentialsError with GKE cluster (intermittently) issue
DefaultCredentialsError with GKE cluster (intermittently) ... --format=json cmd-path: /usr/lib/google-cloud-sdk/bin/gcloud expiry: "2019-11-05T22:55:03Z" ...
Read more >
Service Account Authentication via Secret Key JSON file (for ...
I need to authenticate with Google Cloud Platform to access ... DefaultCredentialsError: ('File /tmp/creds.json is not a valid json file.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found