This was the War of 1812, the origins of which are lost to history. The British government claimed that President James Madison had designs on the British king's lands in Canada, and so it attacked the U.S. The Americans argued that the British government's stated reason for its attack was a pretense, as its real goal was to re-capture what many Britons still considered to be their colonies.
They thought this even though the Treaty of Paris, signed by the United States and Great Britain in 1783, unambiguously recognized the United States of America as a free, independent and sovereign nation.
Notwithstanding its origins, the War of 1812 brought Americans perilously close to being British subjects again. Both the U.S. Capitol and the White House were burned and severely damaged, with President and Mrs. Madison narrowly escaping.