Happens due to gps drifting causing a 15 minute ban.
Here's how to avoid it.
Go go to the gym. Choose all your Pokemon. When you press fight, turn off your GPS/Location services.
The game just locks you at the place you were standing for the entire battle and you will not get that error (from GPS drift) at all.