It can happen. But a lot will depend on your circumstances and the mortgage interest rate you are willing to pay. Generally, most lenders will consider your request for a home loan two to four years after your foreclosure. Predatory lenders will issue a home mortgage in less time. But beware; they routinely charge high mortgage interest rates, fees and penalties for this privilege.
A quality lender will expect you to show that you have cleaned up your credit. Providing a reasonable explanation about the circumstances that led to the foreclosure, such as exuberant medical expenses, is also helpful.