If you have a Windows 7 or 8 PC, the drivers for Nexus 5 will be automatically installed the first time you connect the device to your PC. What drivers get installed depends on what mode the USB connection is on. A certain set of drivers get installed if the USB is connected as a Media device or MTP mode (this is the default) and a different set of drivers get installed if it is connected as a Camera or PTP mode.
Now, the other day I tried to root the device for which I had to put Nexus 5 in USB debugging mode and also uncheck MTP mode. In the process I figured out that the device itself is not getting recognized by the PC. It was fine before but as soon as I unchecked MTP, it stopped getting recognized.
Where are USB connectivity options on Nexus 5?
I had a hard time figuring out where these options are on the Nexus 5 since nothing was appearing in the notification tray when I connect it to the computer. After sometime, I found those options under Storage settings (as seen in the pictures). Select one of them and connect to your PC again and your device should now be recognized again.
If not, you can start from the beginning by removing any existing phone drivers from your PC and then connecting the device with MTP or PTP checked. To do this, connect your phone to the PC and go to Device Manager. Try connecting phone in all three modes, MTP, PTP and USB Debugging (if you have ever enabled this in the Developers options). In the Device Manager section, find anything that resembles drivers of a phone (Google Nexus, Samsung etc) and uninstall them. Additionally, you could download the free USBDview software and uninstall everything that says Google Nexus or Samsung.
Restart your PC and connect your phone in MTP mode letting the PC install the drivers itself. You should now find that your phone is again getting recognized.