There is no fixed rule and in general you may go in as early as you want. Airports are often closed during the night, so if your flight is in the morning you can go through security either a few hours before your flight, or the night before and sleep at the airport (would not recommend).