diff --git a/lib/jnpr/junos/facts/domain.py b/lib/jnpr/junos/facts/domain.py
index ed104f01..92eb03ad 100644
--- a/lib/jnpr/junos/facts/domain.py
+++ b/lib/jnpr/junos/facts/domain.py
@@ -1,4 +1,5 @@
 from jnpr.junos.utils.fs import FS
+from jnpr.junos.exception import RpcError
 from lxml.builder import E
 
 
@@ -11,14 +12,17 @@ def facts_domain(junos, facts):
         facts['domain']
         facts['fqdn']
     """
-    # changes done to fix issue #332
-    domain_filter_xml = E('configuration', E('system', E('domain-name')))
-    domain = junos.rpc.get_config(domain_filter_xml)
-    domain_name = domain.xpath('.//domain-name')
-    if len(domain_name) > 0:
-        facts['domain'] = domain_name[0].text
-        facts['fqdn'] = facts['hostname'] + '.' + facts['domain']
-        return
+
+    try:
+        domain_filter_xml = E('configuration', E('system', E('domain-name')))
+        domain = junos.rpc.get_config(domain_filter_xml)
+        domain_name = domain.xpath('.//domain-name')
+        if len(domain_name) > 0:
+            facts['domain'] = domain_name[0].text
+            facts['fqdn'] = facts['hostname'] + '.' + facts['domain']
+            return
+    except RpcError:
+        pass
 
     fs = FS(junos)
     file_content = fs.cat('/etc/resolv.conf') or fs.cat('/var/etc/resolv.conf')

Domain fact gathering not in try block, RPCerror uncaught.
Was using 1.1.0 until this morning with ssh key authentication.  After upgrade, connecting to the devices fails:

   
    from jnpr.junos import Device
    
    router = 'somerouter'
    username = 'netconf'
    path2keyfile = 'path2privatekey'
    
    dev = Device(router, user=username, ssh_private_key_file=path2keyfile)
    
    dev.open()
    


Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/jnpr/junos/device.py", line 494, in open
    self.facts_refresh()
  File "/usr/local/lib/python2.7/dist-packages/jnpr/junos/device.py", line 758, in facts_refresh
    gather(self, self._facts)
  File "/usr/local/lib/python2.7/dist-packages/jnpr/junos/facts/domain.py", line 16, in facts_domain
    domain = junos.rpc.get_config(domain_filter_xml)
  File "/usr/local/lib/python2.7/dist-packages/jnpr/junos/rpcmeta.py", line 43, in get_config
    return self._junos.execute(rpc)
  File "/usr/local/lib/python2.7/dist-packages/jnpr/junos/decorators.py", line 71, in wrapper
    return function(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/jnpr/junos/decorators.py", line 26, in wrapper
    return function(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/jnpr/junos/device.py", line 569, in execute
    raise e(cmd=rpc_cmd_e, rsp=rsp)
jnpr.junos.exception.PermissionError: PermissionError(severity: error, bad_element: system, message: permission denied)


rolled back to 1.1.0 to confirm, and authentication was successful. With both versions, the target router logs the following in 'messages':
    Jun 11 11:43:31  sshd[1258]: Accepted publickey for netconf from x.x.x.x port 40132 ssh2
    Jun 11 11:43:31  sshd[1258]: subsystem request for netconf by user netconf


I am able to login interactively with the username/key combination.

diff --git a/tests/unit/facts/test_domain.py b/tests/unit/facts/test_domain.py
index 62062557..e92a3313 100644
--- a/tests/unit/facts/test_domain.py
+++ b/tests/unit/facts/test_domain.py
@@ -8,6 +8,7 @@ from lxml import etree
 
 from jnpr.junos.facts.domain import facts_domain
 from jnpr.junos import Device
+from jnpr.junos.exception import RpcError
 
 
 @attr('unit')
@@ -61,3 +62,16 @@ class TestDomain(unittest.TestCase):
         facts_domain(self.dev, self.facts)
         self.assertEqual(self.facts['domain'], 'testing.net')
         self.assertEqual(self.facts['fqdn'], 'test.testing.net')
+
+    @patch('jnpr.junos.facts.domain.FS.cat')
+    def test_domain_rpc_error(self, mock_fs_cat):
+        self.dev.rpc.get_config = MagicMock(side_effect=RpcError)
+        mock_fs_cat.return_value =\
+            """# domain juniper.net
+        search englab.juniper.net spglab.juniper.net juniper.net jnpr.net
+        nameserver 10.11.12.13
+        """
+        self.facts['hostname'] = 'test'
+        facts_domain(self.dev, self.facts)
+        self.assertEqual(self.facts['domain'], 'juniper.net')
+        self.assertEqual(self.facts['fqdn'], 'test.juniper.net')

pip install -e .[dev]
parse_log_pytest
requirements.txt
coverage mock nose pep8 pyflakes coveralls ntc_templates cryptography==3.2 pytest
apt-get update apt-get install -y gcc
3.7
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
bcrypt==4.2.1
certifi @ file:///croot/certifi_1671487769961/work/certifi
cffi==1.15.1
charset-normalizer==3.4.1
coverage==6.5.0
coveralls==3.3.1
cryptography==44.0.2
docopt==0.6.2
exceptiongroup==1.2.2
future==1.0.0
idna==3.10
importlib-metadata==6.7.0
iniconfig==2.0.0
Jinja2==3.1.6
-e git+https://github.com/Juniper/py-junos-eznc.git@d850258f53611146f48db76842108beb9c4060b3#egg=junos_eznc
lxml==5.3.1
MarkupSafe==2.1.5
mock==5.2.0
ncclient==0.6.19
netaddr==1.3.0
nose==1.3.7
ntc_templates==4.0.1
packaging==24.0
paramiko==3.5.1
pep8==1.7.1
pluggy==1.2.0
pycparser==2.21
pyflakes==3.0.1
PyNaCl==1.5.0
pytest==7.4.4
PyYAML==6.0.1
requests==2.31.0
scp==0.15.0
six==1.17.0
textfsm==1.1.3
tomli==2.0.1
typing_extensions==4.7.1
urllib3==2.0.7
zipp==3.15.0

name: py-junos-eznc
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - bcrypt==4.2.1
      - cffi==1.15.1
      - charset-normalizer==3.4.1
      - coverage==6.5.0
      - coveralls==3.3.1
      - cryptography==44.0.2
      - docopt==0.6.2
      - exceptiongroup==1.2.2
      - future==1.0.0
      - idna==3.10
      - importlib-metadata==6.7.0
      - iniconfig==2.0.0
      - jinja2==3.1.6
      - lxml==5.3.1
      - markupsafe==2.1.5
      - mock==5.2.0
      - ncclient==0.6.19
      - netaddr==1.3.0
      - nose==1.3.7
      - ntc-templates==4.0.1
      - packaging==24.0
      - paramiko==3.5.1
      - pep8==1.7.1
      - pluggy==1.2.0
      - pycparser==2.21
      - pyflakes==3.0.1
      - pynacl==1.5.0
      - pytest==7.4.4
      - pyyaml==6.0.1
      - requests==2.31.0
      - scp==0.15.0
      - six==1.17.0
      - textfsm==1.1.3
      - tomli==2.0.1
      - typing-extensions==4.7.1
      - urllib3==2.0.7
      - zipp==3.15.0
prefix: /opt/conda/envs/py-junos-eznc

tests/unit/facts/test_domain.py::TestDomain::test_domain_rpc_error
tests/unit/facts/test_domain.py::TestDomain::test_domain_in_configuration tests/unit/facts/test_domain.py::TestDomain::test_resolv_conf tests/unit/facts/test_domain.py::TestDomain::test_resolv_conf_file_absent_under_etc tests/unit/facts/test_domain.py::TestDomain::test_resolv_conf_no_domain
lib/jnpr/junos/facts/domain.py
lib/jnpr/junos/facts/domain.py