The error “The URL no longer exists” (or a generic 404 Not Found page) typically appears immediately following a sandbox refresh when navigating to custom buttons, detail links, Visualforce pages, or external integration endpoints. When an administrator refreshes a sandbox, Salesforce duplicates metadata and creates the environment on a new infrastructure pod. This process updates domain names, resets object IDs, and renders hardcoded URLs, custom settings, and stale browser sessions invalid.
Fast Fix
Ensure you are accessing the sandbox using its updated Enhanced Domain format (
https://MyDomainName--SandboxName.sandbox.my.salesforce.siteor.lightning.force.com). Clear your browser cache and cookies forsalesforce.com. Then, audit and update hardcoded instance URLs (e.g.,cs42.salesforce.com) in Custom Settings, Named Credentials, and formula links to use relative paths.
Diagnostic Snapshot
- Error Signatures:
The URL no longer exists,HTTP 404 Not Found,Invalid Page URL,Redirected to an unexpected login screen. - Primary Scope: Custom Links, Detail Page Buttons, Visualforce controllers, Experience Cloud portals, SSO identity assertions, and Named Credentials.
- Root Mechanism: Routing failure caused by pod/instance reassignment, Enhanced Domain URL restructuring, or hardcoded legacy URLs.
- Permissions Required: System Administrator access to edit Setup configurations, Custom Metadata, and App Builder page layouts.
Why the URL Breaks After a Sandbox Refresh
When you refresh a sandbox:
- Pod Reassignment: The sandbox rarely stays on the same physical infrastructure server. An org hosted on
CS42prior to the refresh might be reassigned toCS110. Any link, button, or integration script pointing explicitly tocs42.salesforce.comimmediately breaks. - Enhanced Domains: Modern Salesforce environments use Enhanced Domains. The structure for sandboxes includes the sandbox name directly within the domain (e.g.,
company--uat.sandbox.lightning.force.com). References that omit the sandbox subname or use deprecated formats fail to resolve. - Record ID Regeneration: In Developer and Developer Pro sandboxes, records are not copied over from Production. If a custom button or formula links to a specific hardcoded record ID (such as a default Price Book or Public Folder ID), that ID does not exist in the refreshed sandbox, triggering a “URL no longer exists” error.
- Metadata Overwrites: The refresh overwrites all sandbox Custom Settings, Custom Metadata, and Named Credentials with Production values. If your production environment points to live external endpoints, the sandbox inherits those configurations, breaking local sandbox testing pathways.
Diagnostic Path: Tracing the Broken Link
"URL No Longer Exists" Error Encountered
├── When opening the Salesforce Sandbox directly?
│ ├── Check browser URL: Are you using old pod instances (csXX)?
│ └── Action: Log in via <https://test.salesforce.com> and update bookmarks
├── When clicking a Custom Button / Formula Link?
│ ├── Inspect button definition: Is the URL hardcoded or relative?
│ └── Action: Convert absolute URL to relative path (e.g., /lightning/r/...)
└── When accessing an Integration or External Callback?
├── Check Named Credentials / Remote Site Settings
└── Check Connected App OAuth callback URLs
Step-by-Step Resolution
Step 1: Clear Stale Browser Authentication
Browsers frequently cache redirect headers and authentication cookies across sandboxes that share similar domain roots.
- Completely clear your browser cookies and site cache for
salesforce.comandforce.com. - Do not use an old browser bookmark containing an instance pod (e.g.,
cs88.lightning.force.com). - Log in directly through the universal sandbox gateway:
https://test.salesforce.com. - Allow the platform to redirect you to the canonical Enhanced Domain URL. Bookmark that specific landing page.
Step 2: Convert Hardcoded Custom Buttons to Relative URLs
Inspect the custom link or button throwing the error:
- Go to Setup > Object Manager > select the relevant object.
- Click Buttons, Links, and Actions.
- Select the failing button and click Edit.
- Check the Content Source and URL definition.
The Broken Format (Absolute Instance URL):
<https://cs42.salesforce.com/apex/CustomInvoicePage?id={!Account.Id}>
The Corrected Format (Relative URL):
/apex/CustomInvoicePage?id={!Account.Id}
For Lightning Experience record pages, use modern relative routing rather than full system addresses:
/lightning/r/Account/{!Account.Id}/view
Relative paths allow the browser to append the active domain automatically, ensuring the link works in Production, refreshed sandboxes, and scratch orgs without manual intervention.
Step 3: Audit Post-Refresh Custom Settings and Named Credentials
Because the refresh mirrors production data, integrations and endpoints are frequently overwritten with production endpoints or broken sandbox references.
- Navigate to Setup > Custom Settings and Custom Metadata Types.
- Locate any configuration records storing base URLs (e.g.,
Base_URL__corAPI_Gateway__c). - Update the values to match your active sandbox domain or mock integration endpoints.
- Go to Setup > Named Credentials.
- Update your endpoints and re-authenticate any OAuth-based integrations. If third-party authentication handshakes fail after updating endpoints, review How to Resolve: Salesforce “Connected App” failing OIDC Handshakes.
Step 4: Fix Visualforce and Experience Cloud Site Domains
If the missing URL error occurs when opening a Visualforce page or an Experience Cloud preview:
- Navigate to Setup > Sites or Digital Experiences > All Sites.
- Verify whether the sandbox site URL reflects the refreshed domain.
- If the page uses an older Lightning Out or iframe dependency, ensure the Visualforce domain (
c.vf.force.com) matches your updated sandbox name under Enhanced Domains.
Preventive Architecture: Post-Copy Scripts
To prevent manual remediation every time an org is refreshed:
- Build an Apex SandboxPostCopy interface class.
- When initiating a refresh, select this class in the Sandbox Options menu.
- The script executes automatically in the background post-refresh, updating Custom Settings, resetting integration endpoints, and sanitizing configuration records without requiring manual admin intervention. If background synchronization or post-deployment tasks lag behind, see Troubleshooting: Salesforce “Sandbox” sync lag after Deployment.
global class PrepareSandboxEnvironment implements SandboxPostCopy {
global void runApexClass(SandboxContext context) {
// Automatically set the sandbox base URL in Custom Settings
Environment_Config__c config = Environment_Config__c.getOrgDefaults();
config.API_Endpoint__c = '<https://api-sandbox.example.com>';
upsert config;
}
}
Hard Stops
- Never hardcode production credentials or production endpoints into a sandbox to bypass a broken URL. Pointing a sandbox at production APIs or payment gateways risks corrupting production data and overwriting active records.
- If users receive an access error rather than a 404 or missing page notification, the URL structure itself may be valid while profile permissions are blocked. Verify user profile assignments using Fix: Salesforce “You do not have the required permissions” (Identity Loop).