Error: "Session expired or invalid" directly after login
If you encounter the error message "Session expired or invalid" immediately after logging, this guide will help you resolve it. This error typically occurs due to a mismatch in session security settings.
Log in to Salesforce as a System Administrator.
Navigate to Setup.
In the Quick Find box, type Session Settings and select it.
Locate the checkbox labeled Lock sessions to the IP address from which they originated.
Uncheck this option.
Click Save.

Disabling this setting allows sessions to function across different IP addresses, preventing the error from occurring.
Security Consideration: Disabling the "Lock sessions to the IP address" setting may reduce security in environments where IP restrictions are a critical part of the security model. Consider implementing IP ranges or other security measures if needed.
Hyperforce Instances: This issue is particularly common in Salesforce Hyperforce instances, so the resolution is especially relevant for users operating in these environments.
If the error persists after applying this fix or if you have additional security concerns, contact Salesforce Support for further assistance.
1. Disable the "Lock sessions to the IP address from which they originated" Setting
Log in to Salesforce as a System Administrator.
Navigate to Setup.
In the Quick Find box, type Session Settings and select it.
Locate the checkbox labeled Lock sessions to the IP address from which they originated.
Uncheck this option.
Click Save.

Disabling this setting allows sessions to function across different IP addresses, preventing the error from occurring.
Additional Notes
Security Consideration: Disabling the "Lock sessions to the IP address" setting may reduce security in environments where IP restrictions are a critical part of the security model. Consider implementing IP ranges or other security measures if needed.
Hyperforce Instances: This issue is particularly common in Salesforce Hyperforce instances, so the resolution is especially relevant for users operating in these environments.
If the error persists after applying this fix or if you have additional security concerns, contact Salesforce Support for further assistance.
Updated on: 15/01/2025