Error 500 occurs when a user tries to add their SSH key

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

Symptoms

Bitbucket Server shows Error 500 when a user tries to add a public SSH key to their profile.

(Auto-migrated image: description temporarily unavailable)

Diagnosis

Check the atlassian-bitbucket.log file for the following error:

1 2 3 4 5 6 7 8 9 10 11 12 13 ERROR [http-nio-10009-exec-7] @XWEJ1Cx112x323556x0 xxxx 127.0.0.1,0:0:0:0:0:0:0:1 "GET /mvc/error500 HTTP/1.1" c.a.s.i.web.ErrorPageController There was an unhandled exception loading [/plugins/servlet/ssh/account/keys] com.google.common.util.concurrent.UncheckedExecutionException: com.atlassian.util.concurrent.LazyReference$InitializationException: java.lang.IndexOutOfBoundsException: Index: 0 [...] Caused by: com.atlassian.util.concurrent.LazyReference$InitializationException: java.lang.IndexOutOfBoundsException: Index: 0 [...] Caused by: java.lang.IndexOutOfBoundsException: Index: 0 at java.util.Collections$EmptyList.get(Collections.java:4454) at com.google.common.collect.Iterables.get(Iterables.java:728) at com.atlassian.bitbucket.internal.ssh.server.DefaultHostKeyPairProvider$1.lambda$$0(DefaultHostKeyPairProvider.java:54) at com.atlassian.util.concurrent.Lazy$Strong.create(Lazy.java:85) at com.atlassian.util.concurrent.LazyReference$Sync.run(LazyReference.java:325) at com.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:143)

Cause

The server you are running Bitbucket Server on cannot load additional SSL modules as it is most probably running out of memory.

However, as it still runs within the pre-allocated heap space the application itself is stable and doesn't produce any visible signs of insufficient memory.

There might be two possible causes:

  1. You've allocated too much heap space (using -Xms and -Xmx parameters) to your Bitbucket Server and there is no more memory available for other processes to run on the server.

  2. Your system is under heavy load and other processes use all the memory and a yellow banner stating "Bitbucket Server is reaching resource limits" appears in your application.

Solution

Resolution

Ad 1. The default heap space allocation for Bitbucket Server is between 512 and 1024 MB and it works well for customers with large instances in our experience as Bitbucket Server's heap size has zero impact on hosting operations. Most of the memory usage in a server running Bitbucket Server is on the forked git processes. So allocating more memory to the Bitbucket Server JVM won't help your instance scale and perform better. Please make sure your Bitbucket Server application doesn't use most of the server memory by keeping the -Xms and -Xmx parameters at reasonably low level.

Ad 2. Please follow the steps you can find in Bitbucket Server is reaching resource limits article to troubleshoot the memory issues.

Updated on April 2, 2025

Still need help?

The Atlassian Community is here for you.