Who doesn't enjoy gathering around a roaring bonfire, maybe on the beach or campground, to sing songs and enjoy the outdoors? Bonfires can even be useful, especially to burn trimmings from trees or that pile of autumn leaves.

But as enjoyable or useful as a bonfire may be, it’s still fire, and it’s still dangerous. In April, four people in eastern Idaho, including two teenagers, suffered severe burns when their recreational bonfire exploded after a participant poured gasoline on it.

While you'll need to ask your city or county authorities for local burn regulations, here are some general guidelines designed to help you prepare and control a safe blaze.

Related: 8 Flammable Liquids Lying Around Your House

What to burn

The safest fuel is seasoned, untreated and unpainted hardwood without nails. Soft woods like cedar and pine are moist and will throw potentially dangerous sparks into the air, according to UC Irvine Health.

What about yard waste? It may be tempting to burn leaves, grass clippings, tree stumps, tree and shrub trimmings and the like. But yard waste fires produce smoke that can cause health problems for people with respiratory ailments, such as allergies, emphysema, asthma or chronic bronchitis, according to EPA. Some communities allow it so long as you follow local regulations, while others ban it completely. Check with your local town hall for the rules in your area. Many government agencies recommend composting as a healthier and more environmentally friendly practice.

Related: Ban These 7 Allergens From Your Home

What not to burn

Don't burn wood that has been treated with preservatives, which can release toxic gasses into the air. Older treated lumber is especially dangerous because it may contain arsenic, according to the University of Tennessee.

Other materials that you shouldn't burn include:

  • Trash, paint, aerosol cans, plastics and other household waste, which release such toxic chemicals as hydrochloric acid and dioxins, according to the Environmental Protection Agency (EPA).
  • Rubber items, such as auto tires that produce black smoke and can roll off the bonfire and into the crowd while aflame. Plus, a burning passenger-car tire produces, on average, over two gallons of oil, according to the EPA.
  • Corrugated cardboard and other paper products, which create a light ash that blows into the air, according to Kent Fire and Rescue in the United Kingdom. Recycle those things instead.

Where to burn

Try to locate the site upwind of your neighbors. Be courteous and let them know about your plans. Don't light the fire if your neighbors have their windows open or are spending time outdoors.

Set the fire a safe distance from buildings, fences, hedges, brush, trees and roads, which might range anywhere from 25 to 150 feet or more. Local codes may specify the legally required distances in your area.

Clear the area around the fire until there's only bare soil. If a fire pit or ring already exists, use that instead.

Check the weather forecast for windy conditions, when smoke and fire can easily spread out of control. If necessary, postpone the burn for another day.

When you light it

Don't use fire accelerants, such as barbecue lighter fluid or gasoline. They are very dangerous, as the Idaho case shows. On beaches, accelerants can even poison the sand, according to the National Park Service.

Keep an eye on the children. Don't allow them within at least three feet of the fire pit. UC Irvine Health suggests managing children around a bonfire with as much caution as you would use with kids around a pool.

Local codes often require the presence of a fire extinguisher, garden hose, water buckets and/or shovels. The extinguisher should have a minimum UL label rating of “4-A”, which indicates a five-gallon capacity and the ability to extinguish burning wood, paper and other ordinary combustibles.

Before leaving the site, extinguish the fire completely. Don't bury hot wood in dirt or sand — it can continue to burn for up to 24 hours. Instead, pour water over the fire every five minutes until extinguished, according to UC Irvine Health.

Related: What to Do When a Wildfire Threatens

David Arv Bragi is a freelance journalist and marketing consultant. He has been writing about health and safety issues since the 1990s and currently lives in Portland, Oregon.