Failure to connect on reboot

I am able to connect to the cellular network just fine after I initially load the sketch file. It works every time after I load the file. Once I unplug the device from my USB and plug it back in, it does not connect. If I load the same file again and let it reboot, it works fine the first time. If I unplug it and plug it back in, it will not connect again. What could cause it not to connect after I plug it back up and allow it to start on its own?

I have a follow-up. I'm able to get it to work if I monitor the number of times to retry connection. After 5 failed attempts, I issue a NVIC_SystemReset(); and it works. Something is getting reset when I load a sketch file. When it just looses power and starts up normally it will not work.

Without a wiring diagram and code auto-formatted, then post in code tags, it's impossible to tell.

This even happened with the sample code that comes with the IDE. So I don't believe it is a coding issue. Code shouldn't cause it to run fine after initial loading and then fail after you turn it off and back on with it running the same code. Something with the board is reset on file loading. The NVIC_SystemRest does the same thing the file loading does.

Sorry, I never heard of that.
I am not sure I am understanding your problem. Are you saying if you upload a sketch it works fine but if you power cycle the board it does not run the same sketch?
I hope you also used the reset switch, that causes a reboot without power cycling so that would be good to know.
We really need to see your code to make sure you are not doing something unusual.

When I load the sketch it works and connects to the cellular network. When I power cycle the board it loads and failures to connect to the cellular network. I also tried the reset button, it does restart but has the same connection issue to the cellular network. After all that if I reload the same sketch, it works again and connects to the cellular network. It is very strange. I was able to replicate that with the sample sketch file that comes with the IDE. I first thought it was my code, but when I was able to duplicate it with the sample sketch, it believe it is something when loading a sketch that is reseting something in the board or modem. When I run the system reset command it is apparently duplicate what happens on a sketch load. It is very odd. This is on the MKR NB 1500 board.

Sorry, I have no experience with that board but it does sound like it might be a problem. Good luck.