Failed to load Application Default Credentials – How to solve this Elasticsearch error

Opster Team

Aug-23, Version: 7.13-8.9

Briefly, this error occurs when Elasticsearch cannot access the necessary credentials to authenticate with a service, typically Google Cloud. This could be due to misconfiguration, missing files, or incorrect environment variables. To resolve this issue, ensure that the Google Cloud SDK is properly installed and configured. Also, check that the environment variable ‘GOOGLE_APPLICATION_CREDENTIALS’ is set correctly, pointing to the JSON file containing your service account key. If you’re using a compute engine, make sure it has the necessary permissions to access the service.

This guide will help you check for common problems that cause the log ” failed to load Application Default Credentials ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: repository-gcs, repositories.

Log Context

Log “failed to load Application Default Credentials” classname is GoogleCloudStorageService.java.
We extracted the following from Elasticsearch source code for those seeking an in-depth context :

        }
        if (gcsClientSettings.getCredential() == null) {
            try {
                storageOptionsBuilder.setCredentials(SocketAccess.doPrivilegedIOException(GoogleCredentials::getApplicationDefault));
            } catch (Exception e) {
                logger.warn("failed to load Application Default Credentials"; e);
            }
        } else {
            ServiceAccountCredentials serviceAccountCredentials = gcsClientSettings.getCredential();
            // override token server URI
            final URI tokenServerUri = gcsClientSettings.getTokenUri();

 

 [ratemypost]