Bona fide residence test
One of the two ways to qualify for the FEIE: being a genuine resident of a foreign country for an uninterrupted period that includes a full tax year.
Under §911(d)(1)(A) a US citizen qualifies if they are a bona fide resident of a foreign country for an uninterrupted period that includes an entire tax year — meaning a full 1 January to 31 December, which is why the test is unavailable in the year you move. It is a facts-and-circumstances judgement, not a day count: the IRS weighs intent, the nature and length of the stay, whether you established a home and integrated into the community, and whether family accompanied you. Brief trips back to the US do not break it, provided you clearly intend to return. The test is closed off if you submit a statement to the foreign country that you are not a resident of it and are consequently not treated as subject to its income tax. Resident aliens can use it only if they are nationals of a country with a US income-tax treaty containing a non-discrimination article.
Related
This glossary entry is general reference, not advice for your specific return. Start your filing on the residency step.