One Upload Only?

Hi all. Recently, I got an Arduino Mega 2560 for a little project of mine. However, I seem to have run into an issue regarding code uploading. Whenever I upload code after plugging in my Arduino, the code uploads fine. However, whenever I try a second upload, the Arduino IDE gives me an error (repeating this
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: The device does not recognize the command.)
or hangs on the upload with a full loading bar. I've tried changing USB ports (even 2.0 to 3.0), reinstalling the driver, and using the reset button (which seems to have no effect on my code either) before a code upload. Did I get a bad board, or am I just doing something wrong?

Thanks in advance!

When you get the successful upload, do you need to upload immediately after plugging in the Mega, or can you wait as long as you like after plugging it in and still be able to upload?

I have to upload pretty quickly once it's plugged in. Seems to stop accepting an upload once the code kicks in and starts running.

By "pretty quickly", do you mean within several seconds?

That would be correct, yes.