The 24-year-old second seed was trailing 4-3 in the opening set when he decided he could no longer continue.
"I've had some kind of stomach virus for the last few days," said Hewitt, who was playing in his first event since a Davis Cup tie in mid-July.
"It just got worse and worse.
"I haven't been able to eat anything the last three or four days as well which just really hit me because I've got no energy.
"With the heat today, it just felt like I had nothing out there."
Hewitt's retirement is only his second in 504 career singles starts and the first since July 30, 1999.
Serra now goes on to meet Croatia's Mario Ancic in the second round.
Meanwhile, top seed Rafael Nadal advanced with a tough 6-3, 6-7, 6-3 victory over Spanish compatriot Carlos Moya.