How do airlines replace a pilot at the last minute if they're unable to fly?
The airplanes can't depart without the minimum crew, which means 2 pilots, or 3 if there is a Flight Engineer.
The airlines have &quot;Reserve&quot; and &quot;Ready Reserve&quot; types of duty to cater to this, and pilots will be scheduled for one or the other at different times (depending on seniority and what they bid for).
Reserve is on-call at home, with the ability to show up at the airport within, say, 1 or 2 hours of being called.  This is for pilots who call in sick etc, a number of hours before departure.
Ready Reserve is you show up in uniform and with your gear at the operations dept of the airline and hang around in the crew lounge in case they need a crew right now. If they don't, you go home at the end of your shift without flying.
A pilot who is incapacitated just before a flight will be replaced with someone who is on Ready Reserve, and if none are available, then the flight takes a delay until a Reserve pilot can show up.