Restore Google Nexus 5 IMEI that reads 0 I bought a Nexus 5 on Ebay. It came brand new with all the packaging, but having bought a previous Nexus 5 (directly from Google) this packaging seemed a little suspect (I think it might be a very well made imitation, or a modified LG version of the device. Seemed legit on the website though).

Anyhow, when it arrived i put in a local SIM, but it wouldn't connect to the cellular network, or it would connect intermittently (5-10 seconds and it would drop off). I went into the settings and noticed that the IMEI read '0'. It was on Android 4.4.4.

It seems that if the IMEI is 0, the device would fail security checks (either with the MEID or the IMEI zeroed) and thus not register on the network.

After Googling quite a bit, I came across these answers on StackExchange, however they're not entirely clear:
Nexus 5, IMEI 0, how to restore IMEI? (Refers to a Russian website, and you need to translate to English ... so it's kind of messy)
https://android.stackexchange.com/questions/96397/nexus-5-imei-0-shows-how-to-restore-original-imei

None of these was actually clear and after quite a bit of fumbling about, nothing seems to have worked. So how does one get this fixed?
Finally i found this post on XDA which seems to be a better translation from the Russian page above to English: http://forum.xda-developers.com/google-nexus-5/help/imei-0-efs-backup-t2769023/post60421668#post60421668 . All the files necessary are also attached to the post.

However not all of it is useful, i'll copy-paste the useful parts below, and add comments to things that were important:


Download all the ZIP archives from the post
Install the LG driver 
Install QPST
Copy the entire folder EFS Professional to C:/ drive (Not sure whether
it necessarily has be be the C:/ drive, or you can just have it in a folder somewhere on your machine)
You'll need to root the phone and get shell access through adb.
Either:   


Unpack the archive Nexus5 the root of drive C (this is only necessary if you don’t use WUG);  


Or:  


Use WUG Nexus Root Toolkit (a lot easier):  


Make sure you're running stock Android 5.0.1 (Very important, I tried with 5.1.1 and it failed). Depending on which Android version you're on, you can either upgrade normally till 5.0.1, or use WUG to downgrade to 5.0.1
Root the device using WUG
If necessary, you can reset the IMEI using backups zero IMEI from the archive. To do this, simply make a backup of your EFS in TWRP, then replace in the folder's backup your files on the distribution of similar make and restore EFS. (Mine was already zeroed, so i had no chance of making a backup) If it is already erased and reads 0, then just skip this step.


Still using WUG, click on the Launch the Advanced utilities: 


Install boot [kernel] 5.0.0_diag_BOOT.img from folder "restore_imei_files" (Remember that you were on version 5.0.1 ... if you happen to be on 5.1.1, you may end up in a boot loop like i did ---> So 5.0.1 is very important)

Open a command window (Windows prompt) at the location where adb and fastboot are located (You can do this by navigating to the respective folder, hold "shift" on your keyboard, and right click. In the context menu click "Open command window here").
Type: 


adb shell
su
setprop sys.usb.config diag,adb    (notice the comma between diag and adb) This activates the diagnostic mode on the phone and will avail operations with nvram through the com port.

Open EFS Professional:


(a). Click on Qualcomm NV Tools, Hit connect and go to the Secure Ops tab.
(b). Hit Check off IMEI and MEID and hit 'Read' ... if it's zeros then you know you have to enter the IMEI and MEID
(c). Remove the SIM card from the phone (Note: If you had already removed the SIM card earlier, then you can skip this step)
(d). Enter IMEI and MEID (Note: MEID is just the IMEI without the last two digits). (Note: I found my IMEI laser-burned on to the SIM-card holder)
(e). Hit Write

Reboot the phone and check the IMEI by typing *#06# 
If the IMEI still reads 0, repeat from 9(b) above again, then Read (note ESN now appears), then Write again (ignore the errors) > Reboot and check, it should work. This did it for me