diff --git a/web/pgadmin/tools/sqleditor/utils/query_history.py b/web/pgadmin/tools/sqleditor/utils/query_history.py
index 6019aba3..41c7b974 100644
--- a/web/pgadmin/tools/sqleditor/utils/query_history.py
+++ b/web/pgadmin/tools/sqleditor/utils/query_history.py
@@ -14,11 +14,12 @@ class QueryHistory:
                     QueryHistoryModel.dbname == dbname) \
             .all()
 
+        # In Python 2.7, rec.query_info has buffer data type. Cast it.
         return make_json_response(
             data={
                 'status': True,
                 'msg': '',
-                'result': [rec.query_info for rec in result]
+                'result': [bytes(rec.query_info) for rec in list(result)]
             }
         )
 
