java.lang.Exception: The server at 'https://DOMAIN:7443/arcgis/sharing/rest/oauth2/token' returned an error. code expired [] Code: 500

Last Published: May 21, 2024

Error Message

In high-availability ArcGIS Enterprise deployment, attempting to login to the Web Context URL portaladmin endpoint or WebAdaptor URL portaladmin endpoint fails, and the following error messages are returned:

java.lang.Exception: The server at 'https://server.domain:7443/arcgis/sharing/rest/oauth2/token' returned an error. code expired [] 
Code: 500


In a federated high-availability deployment of ArcGIS Enterprise with built-in authentication, security responsibilities are managed by the primary portal, which also oversees token generation for accessing various URLs. Consequently, attempting to access the portaladmin or serveradmin endpoint may result in a "Token Code Expired" error, attributable to time and time zone discrepancies relative to the primary Portal for ArcGIS machine.

The generated token has a set expiration period. However, due to differing time and time zone settings between the machines, the token expires prematurely.

Solution or Workaround

Ensure uniform configuration of time and time zone across all machines engaged in a high-availability deployment. Administrator rights may be necessary to effect these adjustments.

Following the completion of changes, proceed to restart all machines. 

Article ID:000029271

  • Portal for ArcGIS

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options