It comes from the ASCII C0 [transmission] control code NAK, which means "negative acknowledgment"--something was wrong with the last transmitted data block or command, or the reception of it. As opposed to "ACK", which means a block or command was successfully received and accepted. In the original 1963 standard the mnemonic was "ERR", but changed to "NAK" for the 1965 standard.
In programmer lingo it can means something similar to the original meaning--rejecting a request for faultiness or incompleteness--or it can mean something more like, "no"--answering in the negative.