ERROR
When running a process that involves updating or editing an ArcGIS Server service, such as running a calculation on a field in an attribute table using the Calculate Field tool or running a Python script, the process fails and returns the following error message:
Error: Save edits failed. ERROR: code:504, Your request has timed out., Proxy server got bad address from remote server (verify the server is running).
The following is an example script requesting to update a hosted feature layer definition with ArcGIS API for Python that may result in the same error:
gis = arcgis.GIS(display="<display_name>") item = gis.get_item_by_id("<item_id>") collection = FeatureLayerCollection.fromitem(item) overwrite_result = collection.manager.overwrite(zipfile_path) update_dict = {"capabilities": "Query", "syncEnabled": True} collection.manager.update_definition(update_dict)
When calling the update_definition() function in the script above, the script fails and returns the following error message with the same error code 504:
Error: Exception: Your request has timed out. (Error Code: 504)
The process is unable to complete within the timeout duration set on the hosting server. Depending on the capability of the machine or the service, the process may take a longer time than the timeout duration. When the time taken is longer than the timeout duration set on ArcGIS Server Manager, the process is stopped abruptly as the connection between the service and ArcGIS Pro is stopped.
To solve the issue, increase the service timeout duration on ArcGIS Server Manager. Refer to Problem: Service time out in ArcGIS Notebooks before script completion when run on ArcGIS Server services for more information. This process increases the timeout duration permanently until it is changed again.
Alternatively, when running a Python script, the timeout duration can be set to increase within the script. When running the script to connect to the portal, the expiration parameter can be set as shown in the following example:
gis = GIS("https://machine.domain.com/portal", "username", "password", expiration=9999)
Get help from ArcGIS experts
Download the Esri Support App