diff --git a/TES/tes/apiendpoints.py b/TES/tes/apiendpoints.py
index 5004dd71eea2b9d2f665d117cc24a62be93886a1..5d9bddc44f9dc4253d4afcfc6a9de277f9b005cd 100644
--- a/TES/tes/apiendpoints.py
+++ b/TES/tes/apiendpoints.py
@@ -210,7 +210,7 @@ class JobStat(Resource):
             sshsess = SSHSession.get_sshsession()
             sshsess.refresh()
         except:
-            flask_restful.abort(400, message="Error relating to the ssh sessions")
+            flask_restful.abort(500, message="Error relating to the ssh sessions")
         try:
             cmd = json.loads(request.args.get('statcmd'))
             host = json.loads(request.args.get('host'))
@@ -223,9 +223,9 @@ class JobStat(Resource):
             res = Ssh.execute(sshsess, host=host, user=user, cmd=cmd)
         except SshAgentException as e:
             logger.error(e)
-            flask_restful.abort(400, message="Identity error {}".format(e))
+            flask_restful.abort(403, message="Identity error {}".format(e))
         except SshCtrlException as e:
-            flask_restful.abort(400,message="We're having difficultly contacting {}. We failed with the message: {}".format(host,e))
+            flask_restful.abort(403,message="We're having difficultly contacting {}. We failed with the message: {}".format(host,e))
         if not (res['stderr'] == '' or res['stderr'] is None or res['stderr'] == b''):
             logger.error(res['stderr'])
             flask_restful.abort(400, message=res['stderr'].decode())
@@ -258,13 +258,13 @@ class MkDir(Resource):
             Ssh.sftpmkdir(sshsess, host=params['identity']['site']['host'],
                            user=params['identity']['username'], path=params['path'],name=data['name'], sshport=sshport)
         except SftpPermissionException as e:
-            flask_restful.abort(400,message="You don't have permission to make a directory there")
+            flask_restful.abort(403,message="You don't have permission to make a directory there")
         except SftpException as e:
-            flask_restful.abort(400,message="Something went wrong making that directory")
+            flask_restful.abort(500,message="Something went wrong making that directory")
         except Exception as e:
             import traceback
             logger.error(traceback.format_exc())
-            flask_restful.abort(400,message="Something went wrong creating that directory, probably a bug")
+            flask_restful.abort(500,message="Something went wrong creating that directory, probably a bug")
 
         return
 
@@ -295,7 +295,7 @@ class DirList(Resource):
                 try:
                     dirls = json.loads(res['stdout'].decode())
                 except:
-                    flask_restful.abort(404,message="You don't have permission to view that directory")
+                    flask_restful.abort(403,message="You don't have permission to view that directory")
             else:
                 logger.debug('using ssh.sftpls')