I add some custom option in sample product. I save this product and add changes in custom option.

But I can not save the product. and get this error,

Invalid Form Key. Please refresh the page.

enter image description here

  • Try to re-login in magento 2 admin and again add custom options of product then save product.It should work.
    – akgola
    Jan 10, 2018 at 4:55
  • It not work for me. I tried so many process but not save. @akgola Jan 10, 2018 at 5:28

2 Answers 2


This problem is occurred after adding more custom options and categories in the product so because php.ini file not allowed to add more custom options.

So, we need to change default settings of php.ini file.

If php version 7.1 then,


If php version 7.0 then,


If php version 7.2 then,


Uncomment this value and update this all value in php.ini,

max_input_vars = 200000
max_input_time = 600
max_execution_time = 3600

Then Restart Apache 2 web server, and check it.

sudo service apache2 restart
  • I previously increased max_input_vars to 75000 but still sometimes it showing invalid form key error. Is I need to increase the values for max_input_time and max_execution_time too? Sep 12, 2019 at 10:00
  • Please set max_input_vars = 200000. Sep 24, 2019 at 13:20
  • I solved that issue. It was a different error that caused this issue. Sep 24, 2019 at 13:28

Re-login or else if you are developer then till development you can make this setting :

"Add Secret Key to URLs"->No.

Find below screen-shot for more clarity.

enter image description here

  • I tried but not working. I have so many custom option but not save the product. Have you any other solution? Jan 10, 2018 at 6:08
  • Post your code so we can help you . Jan 10, 2018 at 6:49
  • I install Magento2.2.2 without sample data. Now I add new product and add custom option. After I save the new product. Now I change in custom option and tried to save again than the product not save and give invalid form key error. any idea? Jan 10, 2018 at 7:02
  • I Would suggest don't go for magento 2.2.2 instead of it go with 2.2.2. 2.2.2 have some issues. Jan 10, 2018 at 7:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.