Reset and Compact NuGet package database


Nexus Repository 2 stores NuGet package metadata information and NuGet API Keys in a single H2 database. 

Sometimes resetting the NuGet package metadata may be required to solve a performance issue identified by Sonatype Support.

How to reset the Nexus Repository 2 NuGet database


  1. Schedule downtime for the Repository
    Modifications to the database must be performed when no other process has the database file open and the server is stopped. Scheduled tasks will need to complete after the server is restarted in order for hosted NuGet packages to be available.
  2. Locate your Nexus Repository 2 application directory
  3. Locate your Nexus Repository 2 work directory
  4. Download this bash script to the host where the server is running. Examine the source and make it executable by the operating system user account that owns the server process.


  1. Stop Nexus Repository 2.
  2. Execute the bash script as the operating system user account that would own the server process. This ensures file permissions are not changed.
  3. Make sure no error in "<Nexus Repository 2 work directory>/nuget/odata.trace.db" file.
  4. Start Nexus.
  5. Important: Run a Rebuild NuGet Feed task against each NuGet hosted repository, one at a time. NuGet hosted repository package retrieval will not work until this is complete.
  6. Verify the NuGet API keys are still valid and your NuGet performance issue is resolved.



Have more questions? Submit a request


Article is closed for comments.