Of all the steps mentioned above what have you tried?
So i had this solution last week and the fix for it was not in the ports but in the file permissions AND nginx configurations.
If you have changed NGINX configurations from the NGINX directory ( /etc/nginx/conf.d/frappe* ) this might be the reason and unfortunately using
bench setup nginx will NOT solve the issue, instead, you will need to get a full copy of the nginx configuration file UNEDITED and replace it again.
i had this problem. my solution was copy from: (API)/nodemodules/socket.io-client/dist/socket.io.js To: (Cli)/ and use this js. i think thet is problem of different versions of socket io between client and server.