Whittaker, the UFC middleweight champion, was set to defend his belt at the Rod Laver Arena in Melbourne in the early hours of Sunday morning.
It is the second time that he has been forced out of a fight in his home country, after pulling out of his clash with Luke Rockhold last February.
Whittaker and Gastelum had weighed in and gone through fight week without any issues, but news broke late on Saturday that he had been forced to withdraw.
According to ESPN, Whittaker complained about pain in his abdomen after the weigh-in, and was taken to a local hospital.
While there, he was diagnosed with a hernia and forced to undergo surgery.
Gastelum, who last fought in May 2018 when he beat Ronaldo Souaz, took to Twitter after the news broke to send his best wishes to the champion.
“With much sorrow I write that my fight for the middleweight title is off,” he wrote.
“I’m sorry to everyone that was expecting this great fight, family, friends and followers from around the world.
“God has a reason for doing things and I firmly believe that his plans are much bigger and better than I can even imagine.
“I’m so torn about this situation.
“A lifetime of pursuit to be able to reach this level and I hope none of those efforts will go in vain.
“I wish Robert Whittaker a speedy recovery champ! Get well soon!”
MMA legend Anderson Silva’s fight with rising star Israel Adesanya was promoted to the main event.
The winner will become the mandatory challenger to the middleweight title.
The UFC offered fans full refunds on the doors after news broke.