Sometimes when you create a product with multiple attributes in Magento 2, you may end up with the error message “Invalid Form Key. Please refresh the page.“
Here are ways you can solve this issue:
Solution 1: Increasing
By default, the value of
php.ini is set to 1000. You’ll want to set this to 10000. To edit your
php.ini file, follow these steps:
- Log in to your website server using ssh:
2. Go to the folder containing php.ini and open this file by vi
3. Edit the value of
10000 (or create it if it doesn’t exist yet). Then, press ESC key and type
:wq to save the file.
4. Restart your Mamp or Apache. Now you can save your newly created product without any problem.
Solution 2: Changing your base URL
Another possible reason for this issue is because your base URL is not recognized by the Magento 2 system. This is most commonly seen in local environments (localhost). To get around this, run this command to change your base URL to “127.0.0.1”:
php bin/magento setup:store-config:set --base-url="http://127.0.0.1:8080/"
Or go to your PHPAdmin and find the following table: core_config_data, and change the value of web/unsecure/base_url to 127.0.0.1:
After changing your base URL, flush your cache to apply changes:
sudo rm -rf var/cache var/generation var/page_cache
To learn more knowledge about Magento 1 & 2, you can read our other helpful tutorials.