diff --git a/tes/apiendpoints.py b/tes/apiendpoints.py
index 233b12c07966a38c029ca4d2869cf96bd0f1596b..6e8b429214ae974cc79d63c3999feb6712fc0f5d 100644
--- a/tes/apiendpoints.py
+++ b/tes/apiendpoints.py
@@ -298,7 +298,10 @@ class DirList(Resource):
             res = Ssh.execute(sshsess, host=params['identity']['site']['host'], user=params['identity']['username'],
                                 sshport=sshport,
                                 cmd="{} {} {}".format(site['lscmd'],path,cd))
-            dirls = json.loads(res['stdout'].decode())
+            try:
+                dirls = json.loads(res['stdout'].decode())
+            except:
+                flask_restful.abort(404,message="You don't have permission to view that directory")
         else:
 
             dirls = Ssh.sftpls(sshsess, host=params['identity']['site']['host'],