History

The First Computer Bug: The 1947 Moth and the Word's Longer History

In 1947 operators of the Harvard Mark II taped a real moth into their logbook. See the story of the first computer bug and how debugging became a discipline.

By Zebra Hosting Cloud

Programmers call a mistake in software a "bug", and finding it "debugging". The most famous origin story for the term involves a real insect found inside a computer in 1947. The story is true as far as it goes, but, as often happens with famous stories, the details are a little different from the popular version.

The Harvard Mark II

The Harvard Mark II was an electromechanical computer built at Harvard University for the United States Navy. In 1947 it was running at Harvard in Cambridge, Massachusetts, and it was later delivered to the Naval Proving Ground in Dahlgren, Virginia. It used relays, which are switches operated by electromagnets, rather than electronic valves. Its operators included the mathematician and naval officer Grace Hopper, who had worked on the earlier Mark I.

9 September 1947

On 9 September 1947, the operators found that the machine was malfunctioning. The cause was a moth trapped in one of the relays. They removed it and taped it into the computer's logbook, with a note saying it was the first actual case of a bug being found. The logbook page still exists, and it is held by the Smithsonian's National Museum of American History in Washington, with the moth still attached to the page.

Hopper often told the story in talks, and the incident became linked with her name. It was not she who found the moth, however. The log entry is attributed to members of her team, and she is generally reported not to have been present at the moment. What the operators wrote also indicates that they were making a joke. The word bug was already part of engineering slang, and they were pleased to have found a literal one.

An older word

"Bug" meant a fault in a machine long before 1947. Thomas Edison used the word in the 1870s in correspondence to describe small problems in his inventions. In a letter of 1878 he wrote about finding "bugs" in an invention as he worked through it. The word was in use in engineering for faults in electrical and mechanical equipment, and carried over into computing naturally. The Mark II moth is best seen as a famous early literal example of an expression that was already common.

Grace Hopper's wider legacy

Hopper's importance goes well beyond the moth. She is known for:

  • The first compiler. In 1952 she developed the A-0 system, an early program that translated instructions into machine code.
  • Machine-independent languages. She argued that programmers should be able to write in something close to English.
  • COBOL. She contributed to the language specified in 1959, which was designed for business data processing and is still used in some financial systems.
  • Teaching and advocacy. She retired from the Navy with the rank of rear admiral and continued to speak about computing until her death in 1992.

How debugging works now

Modern bugs are rarely insects, but the process has not changed in essence. You observe unexpected behaviour, reproduce it, narrow down the cause and test a fix. Good habits make the process faster:

  1. Reproduce it. Find the steps that always trigger the problem.
  2. Read the logs. Error logs usually name the file and line where the failure occurred.
  3. Change one thing at a time. Otherwise you can't know what fixed it.
  4. Keep a record. The logbook from 1947 is a good model: write down what you tried and what happened.
  5. Test on a copy. Don't experiment on a live site.

Bugs on a website

SymptomTypical first check
Blank white pagePHP error log, plugin conflicts, memory limit
500 Internal Server ErrorWeb server error log, .htaccess rules, file permissions
Site slow after an updateRecently installed plugins, database queries, caching
Contact form emails not arrivingMail settings, SPF and DKIM records, spam folders

Why the story still resonates

The page in the logbook is satisfying because it makes an abstract idea physical. It also reminds us that computers, however sophisticated, are physical machines. Heat, dust, power surges and failing disks still cause problems in modern data centres, which is why serious hosting providers monitor their hardware and keep spare components ready. Software bugs get more attention, but a failing power supply or network card can take a site down just as effectively as a faulty line of code, and good monitoring covers both.

The lesson for site owners

The operators of the Mark II kept a log, and that is why we still know what happened. Keep logs, backups and notes for your own site, so that you can find the cause when something goes wrong and restore a working state if you need to. Every Zebra Hosting plan includes Plesk, which gives you access to error logs and tools for managing your site, and our knowledgebase lists common errors and fixes. If you need a hand, you can reach the team through the contact page, with support available in 17 languages.