There is no limit to how many times you can fail the FAA written test. You can retake the test as much as you want as long as you have waited for a minimum of 30 days between each one. It would be wise to continue your learning during these 30 days to avoid failing again.
The only issue with repeating your FFA is that you might have to ask your instructor to sign off on multiple attempts. The first shouldn’t be an issue, although it is down to their discretion whether they sign off on your third or fourth attempt.
Putting in the work to prevent failing again will make your instructor more likely to sign off on multiple attempts. If they don’t think that you are likely to pass within 30 days, they might hold off on signing your documents to prolong your learning.
An incentive to pass your written test as quickly as possible might be the fee that you’ll have to pay every time you take it. The FAA written test will range in price depending on your location, although they generally range from $140 to $165.