Red Badger awakened me to the thought that your question is geographic rather than chronologic. Which is it?
Since John’s father was a priest in Jerusalem we can assume he lived there as well, but not necessarily, since priestly duties rotated, so he could have lived near Nazareth where Mary lived and stayed in Jerusalem only while performing his duties as a priest.
Distance from Bethlehem to Jerusalem is about 5 and a half miles.
Distance from Nazareth to Jerusalem is about 64.5 miles..........