The causes of the War of 1812 started a medium-scale war between the British Empire and the United States from 1812 to 1815. It began in June 1812 when Congress voted for war following a strong message from President James Madison. The main causes were Britain's need for sailors to fight Napoleon, and its plan to restrict foreign trade entering France. The Americans denounced these goals as a violation of American rights, and were further angered at the use of Canada as a base for Indian raids on the American frontier. The war was strongly opposed by New England and the Northeast, but the "War Hawks" pushed it through.
The British were engaged in a life-and-death war with Napoleon and could not allow the Americans to help the enemy, regardless of their theoretical neutral rights to do so. As Horsman explains, "If possible, England wished to avoid war with America, but not to the extent of allowing her to hinder the British war effort against France. Moreover...a large section of influential British opinion, both in the government and in the country, thought that America presented a threat to British maritime supremacy." 
The British had two goals: all parties were committed to the defeat of France, and this required sailors (hence the need for impressment), and it required all-out commercial war against France (hence the restrictions imposed on American merchant ships). On the question of trade with America the British parties split. As Horsman argues, "Some restrictions on neutral commerce were essential for England in this period. That this restriction took such an extreme form after 1807 stemmed not only from the effort to defeat Napoleon, but also from the undoubted jealousy of America's commercial prosperity that existed in England. America was unfortunate in that for most of the period from 1803 to 1812 political power in England was held by a group that was pledged not only to the defeat of France, but also to a rigid maintenance of Britain's commercial supremacy." That group was weakened by Whigs friendly to the U.S. in mid-1812 and the policies were reversed, but too late for the U.S. had already declared war. By 1815 Britain was no longer controlled by politicians dedicated to commercial supremacy, so that cause had vanished.
The British were hindered by weak diplomats in Washington who misrepresented British policy, and by communications that were so slow the Americans did not learn of the reversal of policy until they had declared war.
When Americans proposed a truce based on British ending impressment, Britain refused, because it needed those sailors. Horsman explains, "Impressment, which was the main point of contention between England and America from 1803 to 1807, was made necessary primarily because of England's great shortage of seamen for the war against Napoleon. In a similar manner the restrictions on American commerce imposed by England's Orders in Council, which were the supreme cause of complaint between 1807 and 1812, were one part of a vast commercial struggle being waged between England and France." 
Question of American expansionism
The idea that one cause of the war was American expansionism or desire for Canadian land was much discussed among historians before 1940, but is rarely cited by experts any more. Some Canadian historians propounded the notion in the early 20th century, and it survives in Canadian mythology.
Madison and his advisors believed that conquest of Canada would be easy and that economic coercion would force the British to come to terms by cutting off the food supply for their West Indies colonies. Furthermore, possession of Canada would be a valuable bargaining chip. Frontiersmen demanded the seizure of Canada not because they wanted the land (they had plenty), but because the British were thought to be arming the Indians and thereby blocking settlement of the west.  As Horsman concludes, "The idea of conquering Canada had been present since at least 1807 as a means of forcing England to change her policy at sea. The conquest of Canada was primarily a means of waging war, not a reason for starting it." Hickey flatly states, "The desire to annex Canada did not bring on the war."  Brown (1964) concludes, "The purpose of the Canadian expedition was to serve negotiation not to annex Canada." Burt, a leading Canadian scholar, agrees completely, noting that Foster, the British minister to Washington, also rejected the argument that annexation of Canada was a war goal. 
Numerous American exiles (United Empire Loyalists) and immigrants had settled in Upper Canada (Ontario). The Loyalists were hostile to reunion with the U.S., while the other settlers seem to have been disinterested. The Canadian colonies were thinly populated and only lightly defended by the British Army, and some Americans believed that the many in Upper Canada would rise up and greet an American invading army as liberators. The combination implied an easy conquest, as former president Thomas Jefferson suggested in 1812, "the acquisition of Canada this year, as far as the neighborhood of Quebec, will be a mere matter of marching, and will give us the experience for the attack on Halifax, the next and final expulsion of England from the American continent."
Violations of American rights
The long wars between Britain and France (1793-1815) led to repeated complaints by the U.S. that both powers violated America's right as a neutral to trade with both sides. Furthermore Americans complained loudly that British agents in Canada were supplying munitions to hostile tribes living in American territory.
Starting in the mid 1790s the Royal Navy, short of manpower, began boarding American merchant ships in order to seize sailors from American vessels. Although this policy of impressment was supposed to reclaim only British subjects, Britain did not recognize naturalized American citizenship, often taking seamen who had been born British subjects but later issued American citizenship certificates. The British believed many of the certificates were invalid. In any case they needed sailors so between 1806 and 1812 about 6,000 seamen were impressed and taken against their will into the Royal Navy. The proposed Monroe-Pinkney Treaty (1806) between the U.S. and Britain was rejected by Jefferson and never ratified because it did not end impressment.
American economic motivations
The failure of Jefferson's embargo and Madison's economic coercion, according to Horsman, "made war or absolute submission to England the only alternatives, and the latter presented more terrors to the recent colonists. The War Hawks who emerged after 1810 included Henry Clay and Felix Grundy of Kentucky; from South Carolina came, John C. Calhoun, Langdon Cheeves, and William Lowndes. Richard M. Johnson came from Tennessee and Peter B. Porter from New York. They succeeded, with Madison's help, in converting wavering Republicans to a defense of the national honor in a demand for complete independence from Britain.
The war hawks came from the West and the South, regions that had supported economic warfare and were suffering the most from British restrictions at sea. The merchants of New England opposed the war; they earned large profits from the wartime carrying trade, in spite of the numerous captures by both France and England, but the western and southern farmers, who looked longingly at the export market, were suffering a depression that made them demand war.  Risjord argued that, "The young war hawks from the South and the West were certainly able men, and largely by force of character alone they led an unwilling and apathetic country to war."
Incidents leading up to the war
This dispute came to the forefront with the Chesapeake-Leopard Affair of 1807, when the British warship HMS Leopard fired on and boarded the American warship USS Chesapeake, killing three and carrying off four "deserters", of whom three were Americans thereby pressed into the Royal Navy. The American public was outraged by the incident, and many called for war in order to assert American sovereignty and national honor.
Meanwhile, Napoleon's Continental System (beginning 1806) and the British Orders in Council (1807) established embargoes that made international trade precarious. From 1807 to 1812, about 900 American ships were seized as a result. The U.S. responded with the Embargo Act of 1807, which prohibited American ships from sailing to any foreign ports and closed American ports to British ships. Jefferson's embargo was especially unpopular in New England, where merchants preferred the indignities of impressment to the halting of overseas commerce. This discontent contributed to the calling of the Hartford Convention in 1814.
The Embargo Act had no effect on Britain and France and was replaced by the Non-Intercourse Act of 1809, which lifted all embargoes on American shipping except for those bound for British or French ports. As this proved to be unenforceable, the Non-Intercourse Act was replaced in 1810 by "Macon's Bill Number 2." It lifted all embargoes but offered that if either France or Britain were to cease their interference with American shipping, the United States would reinstate an embargo on the other nation. Napoleon, seeing an opportunity to make trouble for Britain, falsely promised to leave American ships alone. The lie worked, and the United States reinstated the embargo with Britain and moved closer to declaring war.
In the Congress a group of young Republicans known as the "War Hawks" came to the forefront in 1811, led by Speaker of the House Henry Clay of Kentucky and John C. Calhoun of South Carolina. The War Hawks were nationalists who wanted war to assert America's complete independence from the mother country.
On June 1, 1812, President James Madison sent a message to Congress recounting American grievances against Britain, though not specifically calling for a declaration of war. After Madison's speech, the House of Representatives quickly voted (79 to 49) to declare war, and the Senate by 19 to 13. The conflict formally began on June 18, 1812 when Madison signed the measure into law. This was the first time that the United States had declared war on another nation, and the Congressional vote would prove to be the closest vote to declare war in American history. None of the 39 Federalists in Congress voted in favor of the war; critics of war subsequently referred to it as "Mr. Madison's War."