AFL umpire Dean Margetts will probably chuckle the next time he gets abused by footy fans after he almost died after bursting an ulcer on a flight back to Perth over the weekend.

Margetts had only just finished umpiring the Melbourne and St Kilda NAB Challenge game at Etihad Stadium on Sunday, when he suddenly felt ill on a Virgin flight from Melbourne back to Perth.

AFL umpire Dean Margetts in hospital after an ulcer burst. Credit:Facebook

The next thing the Perth-based umpire knew, the flight was getting diverted to Adelaide and he was rushed to Royal Adelaide Hospital with a hole in his abdomen, which required laparotomy surgery.

"When I got to the hospital and they told me if it burst it could've been fatal, it was pretty overwhelming when I heard that," Margetts told Radio 6PR.