The famous entry
On September 9, 1947, operators of the Harvard Mark II, an electromechanical relay computer, found a moth stuck in one of its relays. They removed it and taped it into the machine’s logbook, with a note that read, in effect, that this was the first actual case of a bug being found. The page survives, and the moth is still attached to it, which makes it one of the best-known objects in computing history.
The Mark II was built at Harvard under Howard Aiken, a pioneer of early computers. It was a successor to the Mark I and used relays, switches that open and close mechanically. A relay is a small gap between electrical contacts, and a dead insect between two contacts could stop the current. The incident is a believable cause of a malfunction.
Who is involved
The story is often linked to Grace Hopper, a mathematician and naval officer who worked on early computers and later helped develop programming languages. Hopper told the story often in later years and helped make it famous. It seems, however, that the logbook entry was written by others on the team, and Hopper may not have been in the room when the moth was found. Accounts of exactly who spotted it differ. It is safe to say that Hopper popularized the tale, and less safe to say she personally discovered the insect.
The joke in the note
The wording of the entry is part of why the story endures. The phrase “first actual case” suggests that the people writing it already used “bug” for a fault and were making a joke, because this time there was an actual insect. That implies the word was already familiar to them. The note therefore confirms the joke, and not the origin, of the term.
An older word
Engineers used “bug” for hidden faults well before 1947. The word had been used in English since at least the 1600s for something that could be a nuisance, and by the late 1800s it appeared in technical settings. Thomas Edison used the word in letters in the 1870s and 1880s to describe small difficulties in his inventions, in the sense of a hidden fault found during development. Later, it was used in aircraft and radio engineering for problems that came from hard-to-find causes.
So the moth did not coin the term. It gave the word a vivid, physical origin story that people found memorable, and the story spread because it was funny and easy to retell.
What “debugging” meant
The verb “debug” also predates computers. It was used in the 1940s in connection with aircraft engines and electronic equipment, where it meant removing defects found during testing. Computer teams adopted it naturally, since early machines often failed from loose connections, burned-out parts and wiring mistakes.
As machines improved, mistakes in the instructions began to matter more than failures of hardware. Maurice Wilkes, who built EDSAC in Cambridge, later recalled that he realized around 1949 that a large part of his future would go to finding errors in programs. That was a turning point: a bug could be in the software, not the machine, and debugging became a skill of its own.
How debugging developed
Early programmers checked their work by reading code, tracing values by hand and stepping through programs one instruction at a time. As computers grew, tools appeared: debuggers that let programmers pause a program, inspect memory and watch variables change. Compilers added error messages, and later testing frameworks automated checks. Careful design practices, code review and logging all try to catch errors earlier.
Some well-known software failures show that costly bugs are not only a joke. Errors in programs controlling machines, finances and communications have caused real losses, which is part of why the field takes testing and review seriously. The scale of modern software, with millions of lines of code, means that no program of significant size is likely to be free of faults, and security researchers study how such faults can be exploited, a topic that connects to cybersecurity.
Where the moth is now
The logbook page is held by the Smithsonian’s National Museum of American History, and it has appeared in exhibits. The moth itself is preserved on the page, a small tan insect under tape.
The real lesson
The first computer bug story is useful because it shows how a popular tale can improve a real event. The moth was real, the entry was real and it was a good joke. The assumption that it was the first bug, or that it invented the word, is where the legend goes beyond the evidence.