[Solution] AWS Java SDK S3 AmazonS3Exception InvalidAccessKeyId

The AWS Access Key Id you provided does not exist in our records. 
(Service: Amazon S3; Status Code: 403; 
Error Code: InvalidAccessKeyId; 
Request ID: 8CYN8...QX4; 
S3 Extended Request ID: /cXoTS2/Fl3Mj....2KjLCxUte4=; Proxy: null), 
S3 Extended Request ID: /cXoTS2/Fl3M....KjLCxUte4=
	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1819)
	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleServiceErrorResponse(AmazonHttpClient.java:1403)
	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1372)
	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1145)

If you are trying to access AWS S3 using the Java SDK and ProfileCredentialsProvider you get AmazonS3Exception InvalidAccessKeyId, the reason could be either of the below,

  • You have provided an invalid aws_access_key_id in your AWS profile credentials in the .aws directory,
  • The Access key must have expired,
  • Check if the access key is not enclosed by double or single quotes, it should look something like the below,

    % cat ~/.aws/credentials
    aws_access_key_id = ABCDEYK2XYZANEEMOVA
    aws_secret_access_key = ABCDEFXyzhFNPwvctQ1X2DEK4k245aDh82a

Try Out Code2care Dev Tools:


Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and software developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include learnings, tutorials, trouble-shooting steps, video tutorials, code snippets, how-to, blogs, articles, etc.

🎉 We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.