Uninstalling a managed package in Salesforce can fail with errors such as "You can't uninstall this package because components in your org reference it." or "Uninstall failed due to unresolved reference."
Custom components reference the package. Components you created outside the package, such as custom fields, Flows, Process Builders, custom buttons, or Apex classes, may reference objects or fields from the managed package. Salesforce prevents the uninstall until all such references are removed.
Recycle Bin items reference the package. Deleted records or components in the Recycle Bin may still hold references to package objects. The uninstall process checks the Recycle Bin and fails if it finds any.
The Download AppExchange Packages permission is missing. The user who performs the uninstall must have the Download AppExchange Packages permission. Without it, the uninstall option is not available.
This article explains how to fix a Salesforce managed package uninstall that fails with a dependency or component reference error. It covers checking permissions, emptying the Recycle Bin, removing component dependencies, and handling "bad reference" errors that require Salesforce Support.
Warning: Emptying the Recycle Bin is permanent. Confirm that no records need to be recovered before proceeding.
Use one of the following methods to identify what is referencing the package:
Once dependencies are identified:
If the dependency view shows no references but the uninstall still fails, the org may have a "bad reference", which is an orphaned metadata reference that cannot be removed through the UI. In this case:
A bad reference is an orphaned metadata dependency that the Salesforce UI cannot display or remove. These occur when components are deleted in a way that leaves behind unreferenced pointers. Salesforce Support can remove these using backend tools.
Check the Recycle Bin for deleted records that might reference the package. Also check for scheduled jobs, email alerts, or workflow rules that reference package objects, because these may not appear in the dependency view.
Yes. For 2GP (second-generation) managed packages, you can use the Salesforce CLI (Command Line Interface) command `sf package:uninstall`. This may succeed in cases where the UI uninstall fails, though dependency errors still apply. Contact Salesforce Support if the CLI uninstall also fails.
005388258

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.