The First Computer Bug: When a Real Moth Changed Tech History Forever
Every programmer knows the frustration of hunting down bugs in their code. But the term “computer bug” has surprisingly literal origins. On September 9, 1947, engineers found an actual moth trapped inside the Harvard Mark II computer, creating one of computing’s most legendary stories.
Table of Contents
The Historic Discovery at Harvard University

The Harvard Mark II was a massive electromechanical computer occupying an entire room and weighing over five tons. On that September afternoon at 3:45 PM, the machine mysteriously stopped functioning. Engineers investigating the malfunction found a moth wedged between relay #70 on Panel F, physically preventing the relay contacts from closing.
What makes this discovery memorable is the documentation. The team carefully removed the deceased moth and taped it into the computer’s logbook with the notation: “First actual case of bug being found.” This physical evidence now resides in the Smithsonian National Museum of American History.
The Truth Behind the Computer Bug Story
While the first computer bug incident is genuine, the popular narrative contains misconceptions. Many credit Grace Hopper with discovering the moth and coining “debugging.” However, historical evidence reveals a different story.

Grace Hopper worked with the Harvard Mark II team in 1947 and helped popularize the debugging story. However, the Smithsonian notes the logbook probably wasn’t hers based on handwriting analysis. The actual person who found the moth remains unknown.
More importantly, the term “bug” predates this incident by decades. Thomas Edison used it in a 1878 letter: “Bugs, as such little faults and difficulties are called, show themselves.” Engineers used “bug” for technical problems throughout the early 20th century, particularly in radar electronics during World War II.
Why the Debugging Term Already Existed
The word “bug” has etymological roots in Middle English, referring to ghosts or hobgoblins. By the 16th century, it described insects, particularly pests. Engineers adopted “bug” as a metaphor for mysterious technical glitches appearing from nowhere.

By Webster’s 1934 dictionary, “bug” was defined as “a defect in an apparatus or its operation.” The term “debug” appeared in a 1945 Journal of the Royal Aeronautical Society, proving it was common engineering slang before the moth incident.
The Harvard team’s notation”First actual case of bug being found” was clearly a joke. They were acknowledging the humor of finding a literal insect when already using “bug” for computer malfunctions.
How Early Computers Attracted Real Bugs
The Harvard Mark II and similar computers generated considerable heat from vacuum tubes and electrical components. Computer rooms stayed warm, creating ideal environments for insects seeking warmth during cooler evenings.

Moths exhibit transverse orientation, navigating by maintaining constant angles to distant light sources. Bright lights and warmth attracted moths through open windows or ventilation systems. Once inside, insects became trapped in mechanical relays, causing hardware failures.
This wasn’t isolated. Engineers regularly dealt with insects interfering with early computing equipment. The Harvard Mark II moth became famous because someone preserved and documented it.
The Legacy of Debugging in Modern Computing
From September 1947, debugging became fundamental to software development. While modern programmers rarely encounter actual insects, the systematic approach to identifying and fixing errors traces back to those early troubleshooting sessions.

Today’s debugging involves sophisticated tools, integrated development environments, automated testing frameworks, and debuggers, letting programmers step through code line by line. The essential principle remains unchanged: methodically tracking down problems, understanding root causes, and implementing fixes.
Research shows debugging consumes significant resources. A 1978 study found projects invested 17% of development effort in bug fixing, while 2020 research on GitHub repositories showed this increased to 20%. NASA’s Goddard Space Flight Center reduced error rates from 4.5 per 1,000 lines down to 1 per 1,000 through rigorous debugging practices.
Grace Hopper’s True Contributions to Computing
While Grace Hopper may not have discovered the first computer bug, her actual contributions to computer science far exceed this anecdote. She became a pioneering figure who made programming more accessible and developed foundational technologies still used today.

Hopper coined the term “compiler” and created one of the first compiler programs, translating human-readable programming languages into machine-executable code. Her work on COBOL (Common Business-Oriented Language), introduced in 1959, revolutionized business data processing by allowing programmers to write instructions in English-like statements.
These achievements earned Hopper the National Medal of Technology in 1969, making her the first woman to receive this honor. She retired from the U.S. Navy as Rear Admiral, cementing her status as one of computing’s most influential figures.
Why This Story Matters for Modern Technology
The first computer bug story endures because it captures something essential about the relationship between humans and technology. Even sophisticated machines can be disrupted by the smallest, most unexpected factors a lesson remaining relevant as we build increasingly complex systems.

This incident symbolizes the cultural shift toward precision and rigor in early computer science. The engineers could have simply removed the moth and moved on. Instead, they documented the moment with humor and care, creating a historical artifact inspiring generations of programmers.
The debugging story reminds us that problem-solving requires patience, systematic investigation, and a willingness to look for unexpected causes. Whether tracking down syntax errors in modern code or removing moths from 1940s hardware, the debugging mindset remains fundamentally the same.
Conclusion: From Moths to Modern Debugging
The tale of the first computer bug bridges computing’s mechanical origins and today’s digital landscape. While the Harvard Mark II moth didn’t create the term “debugging,” it provided a perfect literal example, making the concept memorable.

This September 1947 incident stands as a charming reminder of how far technology has evolved. From room-sized machines vulnerable to wandering insects, we’ve progressed to smartphones with more computing power than those early behemoths. Yet every programmer still faces bugs, still needs debugging skills, and still benefits from the systematic troubleshooting approaches pioneered by early computer scientists.
The preserved moth in the Smithsonian serves as an enduring symbol not just of a single hardware malfunction, but of humanity’s ongoing quest to understand, fix, and improve the technology we create.
7 FAQs About the First Computer Bug

1. Was the first computer bug really a moth?
Yes, on September 9, 1947, engineers found a real moth trapped in relay #70 of the Harvard Mark II computer, though the term “bug” already existed in engineering.
2. Did Grace Hopper discover the first computer bug?
No, while Hopper worked on the Harvard Mark II team, the Smithsonian confirms she likely didn’t discover the moth based on handwriting analysis.
3. When was the term “debugging” first used?
The term “debug” appeared in a 1945 engineering journal, and Thomas Edison used “bugs” for technical faults in 1878, predating the 1947 moth incident.
4. Where is the original computer bug moth now?
The moth is preserved at the Smithsonian National Museum of American History, still taped to the original logbook page.
5. Why did moths get into early computers?
Early computers generated significant heat from vacuum tubes, attracting moths through open windows, which then became trapped in mechanical relays.
6. How has debugging changed since 1947?
Modern debugging uses sophisticated software tools like IDEs and automated testing, but the core principle of systematic problem-solving remains unchanged.
7. What were Grace Hopper’s most important contributions?
Hopper coined the term “compiler,” created early compiler programs, and developed COBOL in 1959, earning her the National Medal of Technology in 1969.