Can not save with "500 Internal Server Error" error

I updated my bench to the latest version 4.1.0 while still keeping frappe and erpnext at 7.x. After the update, I am not able to save “Delivery Note” or customize doctypes using the “Customize Form” tool. Both the actions triggers the same error:

Failed to load resource: the server responded with a status of 500 (Internal Server Error)
Uncaught SyntaxError: Unexpected token < in JSON at position 0
    at JSON.parse (<anonymous>)
    at Object.<anonymous> (desk.min.js:138)
    at i (jquery.min.js:2)
    at Object.fireWith [as rejectWith] (jquery.min.js:2)
    at z (jquery.min.js:4)
    at XMLHttpRequest.<anonymous> (jquery.min.js:4)

I tried reinstalling fresh bench and site, and restored my site too. However, I am still facing the same error. There was also the issue of socketio, however I was able to solve that by updating the socket.io.min.js file to v2.

Anyone faced the same issue or have any idea on how to go about?

Anyone? I am not able to save few important doctypes like Delivery Note, Update Doctypes using “Customize Form”, create a new Doctype, etc.
Basically it is the 500 internal server error that is giving issue since the following error of json parse is trying to parse the 500 error html page.

Maybe it times out.

Check your frappe logs in logs/frappe.log in frappe-bench and also on nginx, supervisor for clues.

I was looking at all the logs in bench folder, and there was no clue in it. I am not sure what actually resolved the issue. I did the following and it is resolved now:

  1. Reinstalled python27 (Python 2.7.5) from entos-sclo-rh repo
  2. Reinstalled nodejs (v6.10.3) from from epel repo (was using nodesource earlier)
  3. Reinstalled nginx