I am trying to query a feature layer from a script using the arcgis api for python:

from arcgis.features import FeatureLayer
lomr = FeatureLayer("https://hazards.fema.gov/gis/nfhl/rest/services/public/NFHL/MapServer/1")

However, when I make a call to view properties, or actually perform a query:

lomr.query(where="DFIRM_ID = '08013C'",outSR=2876,outFields='*')

I get the following error (after quite a long traceback):

ConnectionResetError: [Errno 54] Connection reset by peer

I even get a similar error if I try pasting this query url through the requests library:

import requests
response = requests.get("https://hazards.fema.gov/gis/nfhl/rest/services/public/NFHL/MapServer/1/query?where=DFIRM_ID+%3D+%2708013C%27&text=&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=*&returnGeometry=true&returnTrueCurves=false&maxAllowableOffset=&geometryPrecision=&outSR=2876&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&resultOffset=&resultRecordCount=&queryByDistance=&returnExtentsOnly=false&datumTransformation=&parameterValues=&rangeValues=&f=html")

This seems like a problem on FEMA's side, as I'm guessing "peer" means the server of the client-server request. How do I avoid this error and actually get a successful get request?

[EDIT 1] - I thought this could potentially be a problem with using jupyter notebooks, but I tried this same process through python in the terminal and got the same error.

[EDIT 2] - I have also tried this through a virtual environment set up with pipenv with the same results. I've tried this on macOS and my Windows at work. Here are the versions of everything I'm working with:

pipenv - 2018.11.26
python - 3.7.4
jupyter notebook - 6.0.1
arcgis - 1.6.2

  • Have a look here, might help: community.esri.com/thread/…
    – umbe1987
    Sep 9, 2019 at 14:41
  • @umbe1987 I tried the suggestion listed (using arcgis.mapping) to no avail. Still getting the same error.
    – jesnes
    Sep 9, 2019 at 20:09
  • I just tested your code and it is working from my side (it is returning 17 features) (tested with Jupyer notebook, arcgis API version 1.6.2).
    – umbe1987
    Sep 10, 2019 at 7:17
  • 1
    Have you tried disabling your antivirus? I remember having issues with COMODO. I have ArcGIS Pro 2.4, which comes with the conda console. I cloned the default conda env of ArcGIS Pro and upgraded arcgis package with conda upgrade -c esri arcgis.
    – umbe1987
    Sep 12, 2019 at 8:03
  • 1
    @umbe1987 I got it to run successfully by cloning the conda env that ships with Pro, which means the error must be occurring because of how I initialized my environment with pipenv. I'd still like to solve the underlying issue so people trying to access the api without access to a Pro conda env could do what they need.
    – jesnes
    Sep 13, 2019 at 16:42


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.