Basements, often a cool refuge in the summer, can be deadly traps when a fire breaks out in a home.

Now, a state building code that will take effect Oct. 1 will require homeowners to add fire exits or extra-large windows to basements if they apply for a permit to finish or renovate that area. The new code will not apply to residents who receive a building permit before that date or who already have finished basements.

The code, which will also apply to new construction, comes after several local fires in which people died or were nearly killed because their basements did not have an escape route.

A 32-year-old Merrifield man died when he couldn't get out of his cellar during a fire in April 2002. Four members of a family perished earlier that year in their basement in Montgomery County in similar circumstances.

Last December, two children in Baileys Crossroads were nearly killed when a Christmas tree caught fire in a home they were sharing with two other families. Three people on the first floor died. The two children escaped by squeezing through a basement window with a neighbor's help.

Other fire codes are being scrutinized after a fire last month torched 18 condominiums in Kingstowne and killed three residents.

Several fire officials in Virginia say homes are being built too close together, allowing flames to jump easily between buildings.

National building codes, which states can adopt, call for single-family houses to be built just six feet apart, but in the Kingstowne blaze, radiant heat nearly ignited a building 34 feet away.

According to the National Fire Protection Association, there were 16,500 basement fires nationwide in houses and apartments in 1999, the last year the organization compiled the statistic, said Margie Coloian, director of public affairs. The vast majority of those fires happened at night, when people were sleeping.

Owners of older homes who don't plan to renovate or already have finished basements should also have proper fire exits, officials said.

In December, two children survived a fire in a Baileys Crossroads home by squeezing through a basement window with a neighbor's help, but three people on the first floor died. The new state building code addresses the problem.