diff --git a/lib/spack/spack/monitor.py b/lib/spack/spack/monitor.py index b4e8475e707..4c89b49b71b 100644 --- a/lib/spack/spack/monitor.py +++ b/lib/spack/spack/monitor.py @@ -228,7 +228,7 @@ def issue_request(self, request, retry=True): except URLError as e: # If we have an authorization request, retry once with auth - if e.code == 401 and retry: + if hasattr(e, "code") and e.code == 401 and retry: if self.authenticate_request(e): request = self.prepare_request( e.url,