Whenever I tried to add product to cart from list page or product page in fresh setup Magento Ce 2.1 release it redirects to checkout page and no product gets added.
I tried disabling cache also.
If you ran in local and your path is :localhost please replace "localhost" to "127.0.0.1".
So you can change root URL by SQL query:
UPDATE core_config_data SET value = 'http://127.0.0.1/' WHERE path IN ('web/secure/base_url', 'web/unsecure/base_url');
It is sufficient for Magento 1.x but not for Magento 2.0. Magento 2.0 for some strange purpose additionally stores root URL in the third path: design/head/includes
The record looks like:
<link rel="stylesheet" type="text/css" media="all" href="<root URL>/pub/media/styles.css" />
So you need one more SQL query:
UPDATE core_config_data SET value = REPLACE(value, '<old root URL or domain>', '<new root URL or domain>') WHERE path = 'design/head/includes';
UPDATE core_config_data SET value = REPLACE(value, 'http://localhost/', 'http://127.0.0.1/') WHERE path = 'design/head/includes';
Then delete the cache:
rm -rf var/cache/*
Those who don't wish to change the localhost url and doesn't want to add vhost for this problem. Here's the quick fix.
The problem is due to form_key mismatch. The form key which gets posted during add to cart action is getting mismatched with store session form key.
method. and comment out the first If condition.
**NOTE:**This is not a recommended solution for Production environment.
I am using Mac and I faced this issue using localhost as URL for Magento 2 instances. This is a quick fix if you made a new instance and/or trying to debug something quickly...
Following this answer posted above in this thread fixed my issue.