With the Fourth of July upon us, Mainers are gearing up for their celebrations. If you plan on lighting up the sky, you may want to check to see if that stash of pyrotechnics will get you into trouble.

Since 2012, it has been legal in Maine to buy and sell fireworks. While many areas of the state allow the use of fireworks, some towns and cities have enacted bans on the use and sale of consumer grade fireworks. Bangor for instance has a ban of both the sale and use of fireworks. Fines range from $100 to $1,000 for each offense.

It's Illegal To Use Fireworks In These Bangor Area Towns:

Before you launch your fireworks, it's a good idea to check with your town office. Many communities have time restrictions as to when consumer grade fireworks are permitted.

Brewer, for example, has a designated area where use is permitted. According to the ordnance, "The use of consumer fireworks shall be restricted to those areas of the City of Brewer that permit the discharge of shotguns, muzzle loaders, black powder guns, revolvers and pistols." Using fireworks in areas within the red section of this map is not permitted.

Ellsworth has a similar ordinance, banning the use and sales of fireworks within the city limits. Firework use outside of "Compact Urban Area" is allowed on July 4 and December 31.

Towns with restrictions on fireworks are listed on the Maine State Fire Marshal's website.

Maine's 16 Counties Ranked By How Much Money People Make

Here's the list of every county in Maine ranked by median household income from lowest to highest.

11 Activities in Maine Your Kids Will Actually Want to Do This Summer

Kids enjoy a lot of things but for summertime fun, it all comes down to 5 groups; amusement/water parks, animals, sports, learning, and the beautiful outdoors. If you're looking for some serious family fun this summer, start checking these off your bucket list.

10 Things That Every Mainer Has Out To Camp

LOOK: Full List of the Best Places to Live in Maine

Stacker compiled a list of the best places to live in Maine using data from Niche. Niche ranks places to live based on a variety of factors including cost of living, schools, health care, recreation, and weather. Cities, suburbs, and towns were included. Listings and images are from realtor.com. On the list, there's a robust mix of offerings from great schools and nightlife to high walkability and public parks.

Some areas have enjoyed rapid growth thanks to new businesses moving to the area, while others offer glimpses into area history with well-preserved architecture and museums. Keep reading to see if your hometown made the list.