diff --git a/backend/server.js b/backend/server.js
index db6ddb0af475b9569aea671731df097321288b3a..ded15b90ca54c2222c30a077a5b5f21dce3cfbb4 100644
--- a/backend/server.js
+++ b/backend/server.js
@@ -19,11 +19,11 @@ app.use(logger("dev"));
 app.use(cors());
 app.use(express.json());
 app.use(express.urlencoded({ extended: false }));
-app.use(jsonErrorHandler);
 
 app.use("/", indexRouter);
 app.use("/users", usersRouter);
 app.use(routeNotFoundJsonHandler);
+app.use(jsonErrorHandler);
 
 const port = parseInt(process.env.PORT || "3000");
 
diff --git a/backend/services/jsonErrorHandler.js b/backend/services/jsonErrorHandler.js
index 31652c23f9715732b584ef49268396ef4e4a6450..0a379a251d431f68ff786361424090dda9f7c6d1 100644
--- a/backend/services/jsonErrorHandler.js
+++ b/backend/services/jsonErrorHandler.js
@@ -3,6 +3,9 @@
 // that needs to have four arguments as opposed to a regular middleware.
 // eslint-disable-next-line no-unused-vars
 const jsonErrorHandler = function (error, req, res, next) {
+  console.error(error);
+  if (res.headersSent) return next(error);
+
   if (process.env.NODE_ENV === "development") {
     return res.status(500).json({
       message: error.toString(),