On September 9, 1947, somebody working with one of the most advanced calculating machines in the United States opened its hardware and found an unusually literal explanation for a malfunction: a moth was trapped among the electromechanical relays.
The insect was removed, taped into the machine's logbook and accompanied by a dry joke that would become one of the most famous lines in computing history: “First actual case of bug being found.”
The story is usually told as the moment Grace Hopper invented the computer term “bug.” It is memorable, visual and almost too perfect. It is also not quite true.
The moth was real. The logbook survives. Hopper was part of the Harvard computing team and later helped make the anecdote famous. But engineers had been talking about “bugs” long before electronic computers existed. The joke in the logbook works precisely because everyone involved already knew what a technical bug was.
A bug before computers
Long before programmers blamed bugs for crashed applications, engineers used the word for troublesome defects whose causes were difficult to identify. The Smithsonian National Museum of American History, which preserves the famous Mark II logbook, notes that American engineers had been calling small flaws in machines “bugs” for more than a century and that Thomas Edison used the term in connection with electrical circuits in the 1870s.
This older meaning is crucial to understanding the 1947 incident. The Harvard engineers did not encounter a moth and spontaneously decide that all future computer failures should be named after insects. They were already accustomed to describing technical problems as bugs. Finding an actual insect inside the machine transformed engineering slang into a physical pun.
The word itself has even older associations with annoying or frightening creatures, but by the late nineteenth century “bug” had acquired a recognizable technical sense. As complex electrical systems multiplied, so did faults that could be frustratingly elusive. The metaphor was well suited to a problem that seemed to hide somewhere inside a machine.
Computing inherited that vocabulary from engineering.
The machine was the Harvard Mark II
The computer involved in the famous episode was the Harvard Mark II, also known as the Aiken Relay Calculator. It belonged to the generation of large electromechanical calculating machines developed around the Second World War and the immediate postwar period.
These machines bore little resemblance to today's silent silicon computers. The Mark II relied heavily on electromagnetic relays — electrically controlled switches whose physical contacts opened and closed as the machine operated. A large calculation therefore involved a vast choreography of mechanical switching.
Grace Murray Hopper was already deeply involved in this new world. A mathematician who had joined the U.S. Naval Reserve during the war, she worked at Harvard with Howard Aiken's computing group and programmed the earlier Harvard Mark I as well as its successors. The experience helped launch a career that would eventually make her one of the most influential figures in programming history.
In September 1947, the Mark II team encountered a problem. According to the Computer History Museum's account, a moth was found caught between relay contacts. The insect was removed and attached to the operational log.
The handwritten annotation beside it made the joke permanent: “First actual case of bug being found.”
Was Grace Hopper actually the person who found it?
This is where the familiar story becomes less certain.
Popular retellings often say that Hopper herself discovered the moth, removed it and taped it into her logbook. Some museum summaries have also described the incident in that simplified form. The Smithsonian's detailed catalog record is more cautious: engineers working on the Mark II found the moth, and although Hopper was among those working on the computer, the museum says the surviving logbook was probably not Hopper's personal logbook.
The Smithsonian artifact record credits the Mark II team with finding and preserving the insect, while emphasizing Hopper's role in popularizing both the story and the language of computer “bugs” and “debugging.”
Hopper herself certainly remembered the incident. In a later oral history preserved by the Smithsonian, she described the Mark II team working at night in a building whose windows lacked screens. Insects entered, and when the machine stopped functioning the team found a large moth in a relay. She recalled that they removed it and put it in the logbook under tape.
That testimony places Hopper squarely within the story without requiring us to turn a team event into a solitary eureka moment.
Why the moth could actually stop a computer
To somebody accustomed to microprocessors, the idea that an insect could halt a computer sounds almost comic. With an electromechanical machine, it was entirely plausible.
A relay depends on physical electrical contacts changing state. If foreign material interferes with those contacts, a switch may fail to open or close correctly. One bad relay could disrupt the sequence of operations expected by the machine.
The surviving logbook identifies the insect with Relay #70 in Panel F. The moth therefore belonged to a category of fault that modern software developers encounter less literally: the system behaved incorrectly because one component failed to reach the state expected by the rest of the system.
The scale has changed dramatically. In 1947, troubleshooting might mean examining racks of relays and listening to machinery. Today it may mean inspecting logs, tracing network requests, stepping through code or analyzing billions of operations executed on microscopic transistors. The intellectual process is remarkably familiar: observe the failure, isolate its cause and remove it.
Debugging was not invented that afternoon either
The moth story is also frequently credited with creating the verb “debug.” That, too, should be treated carefully. Forms of the term were already associated with removing faults from technical systems before the Mark II incident.
What Hopper and the early computer community did help accomplish was the migration and popularization of this engineering vocabulary into computing. As programmable machines became increasingly important, “bug” became the natural word for a hardware or software fault, while “debugging” became the process of finding and correcting it.
The transition is historically revealing. Early computing did not invent an entirely new technical language. It borrowed heavily from electrical engineering, mathematics, telecommunications, office machinery and military technology. Words such as memory, register, address and instruction acquired specialized computational meanings in similar ways.
The moth is famous because it captures that transition in a single artifact: old engineering slang meets the emerging profession of computer programming.
Grace Hopper's larger legacy is much more important than the moth
There is a danger in reducing Hopper to a charming anecdote about an insect. Her actual contribution to computing was vastly more consequential.
After Harvard, she worked at the Eckert-Mauchly Computer Corporation and on UNIVAC. She became an important advocate for programming systems that allowed humans to express instructions at a higher level rather than writing everything in machine-oriented notation. Her work on early compilers and the FLOW-MATIC language helped establish ideas that influenced the development of COBOL, the business programming language whose descendants and implementations remain in use decades later.
The National Museum of American History describes Hopper's compiler work and her push toward languages closer to ordinary human language as central parts of her career. She also returned to active naval service and eventually retired as a rear admiral in 1986 at the age of 79.
The moth became the irresistible story because it can be understood in seconds. Compiler design cannot.
The original bug still exists
Unlike many stories from the earliest days of computing, this one comes with extraordinary physical evidence. The logbook page, moth included, survives in the collections of the Smithsonian's National Museum of American History.
The insect remains taped to the paper beside the handwritten remark. It is an unusually tangible relic from a field whose historical artifacts are often lines of code, diagrams or machines too large to preserve easily.
It also preserves the humor of the people who operated early computers. The annotation was not a solemn declaration that a new technical term had been invented. It was a joke among engineers: after years of talking about mysterious “bugs,” they had finally found one with wings.
That is what makes the true version better than the myth. Grace Hopper did not need to invent the word “bug” in 1947. The term had already travelled through decades of engineering culture before reaching computing. What happened at Harvard was stranger and more satisfying: an old metaphor suddenly became literal.
Every time a developer says they are debugging software today, the phrase carries that longer history. Somewhere behind the stack traces, breakpoints and error logs is a nineteenth-century engineering expression — and one unfortunate moth that, for a few minutes in 1947, became the most literal computer bug the world had ever seen.