McHenry is a city in McHenry County, Illinois, United States. It is part of the Chicago metropolitan area and is located about 45 miles northwest of Chicago. The population was 27,135 at the 2020 census. McHenry took its name from the county, which was named for Major William McHenry.