diff --git a/app/js/lib/conf/routes.js b/app/js/lib/conf/routes.js
index 986c0e85b19423b324fc1ad46b9e3b439cac3de9..55af323a81727df004d35cf10bd05a040a2d6abf 100644
--- a/app/js/lib/conf/routes.js
+++ b/app/js/lib/conf/routes.js
@@ -250,6 +250,13 @@ module.exports = (app) => {
     $urlRouterProvider.otherwise('/');
   }]);
 
+  app.run(($rootScope, $state) => {
+    $rootScope.$on('$stateChangeError', (event, toState, toParams, fromState, fromParams, error) => {
+      console.error(error);
+      $state.go('error', { err: error.message });
+    });
+  });
+
   function resolveNetworkAutoConf(BMA) {
     return co(function *() {
       let netinterfaces = yield BMA.webmin.network.interfaces();