In order to fortify my units I have to be in friendly territory. I have had to go into territory for it to work, but sometimes I don't have to. Is there a set number of tiles away that allows for healing? Also, for unit upgrades it says I can only upgrade in friendly territory, but it only works in my own territory. So, I end up spending more time moving my units back and forth than actually fighting. Am I doing something wrong? Is this a glitch, or am I just not getting something?
Fortify/Sleep/Alert - You can do this anywhere. This does two things. First, you are not prompted to move the unit on future turns unless an enemy unit shows up nearby. Second, melee, archer, and gunpowder units receive a defensive bonus.
Heal - Land units can heal anywhere, though they heal faster in your/allied city states territory. Naval units only heal if they are within the borders of a civilization (including city states) you are not at war with, unless the naval unit has the supply promotion, which allows the promoted naval unit to heal anywhere.
Upgrade - You can only upgrade units in your territory (and maybe allied city states)
Healing and upgrading use different definitions of "Friendly Territory".
Fortifying doesn't depend on territory at all. Fortifying gives the unit a defense bonus as long as it doesn't do anything.
Upgrading units requires the unit to be in your territory- the cultural borders of a city you own.
Healing, for land units, can occur anywhere. A unit heals 10 per turn but this is increased to 20 in friendly territory. naval units only heal in friendly territory. For healing, friendly territory is defined as any of the following:
- Your territory
- Territory belonging to a Civ with whom you have an Open Borders agreement
- Territory of a city state which is your friend or ally
In addition to the other answers, I just wanted to add a note about Friendly Territory with regard to city states:
- City state territory counts as Friendly Territory for the Embark upgrade part of the Optics technology. (Applies to: Friends and Allies)