I am not able to ssh to raspberry pi after 2-3 hours. This all started after installing Plex Server on it but not sure if this is a mere conincidence. At first, I got "connection reset by peer" error after typing "ssh user@ip" on the terminal. Assuming, it was a server load problem (hence crashing), I swapped my sdcard from raspberry pi 2 model b+ to raspberry pi 3 after update/upgrade. Now I get "Connection closed by port 22" when i tried to ssh. Tried many computers. All the other non ssh connections also don't work. After every restart it works normally for a few hours. I can successfully ping but can't connect. How I start to debug this issue? Where to look for trouble? How to see server logs? I am running latest version of Raspbian on it. Pi is powered through usb hub. It is connected to wireless network. I wasn't able to ping with raspberry pi 2 model b+ version but after swapping cards to raspberry pi 3, ping works when SSH fails. There is no firewall. It had been working fine with this kinda setup for months. I understand there is some non trivial issue and wondering how to check server logs for trouble. Please advise.
A USB hub powered or otherwise is not able to supply enough power to the Pi. This is likely the cause of your issues. Keep the USB hub for powering the WiFi dongle, and get a proper 5v 2A powersupply.