Conditions of Hajj

1- Islam

Hajj is not prescribed for a disbeliever, and it is not accepted from him.
2- Sanity

It is not prescribed for the insane due to the Prophet’s ﷺ statement: “The pen has been raised (i.e no sins will be recorded) for three people: the sleeping person until he wakes, a child until maturity, a mentally deranged person until consciousness is regained.” [ Abu Dawud.]
3- Puberty

It is not obligatory on minors (children), but if they enter into ihram for Hajj, then their Hajj will be valid. However, this does not suffice for the proper Hajj (when the child attains maturity) i.e. the Hajj (of a young child) is supererogatory as evidenced by the hadeeth of Ibn ‘Abbas t as he stated that a lady went to the Messenger of Allah ﷺ with a child raised up and said, “Can he perform Hajj” and the Prophet said: “Yes, and you will be rewarded.” [ Muslim.]
It is permissible for a child to assume Ihram for Hajj.

4- Freedom

Hajj is not obligatory upon a slave; the Prophet ﷺ said: “Any slave who observed Hajj before his freedom must perform another after his freedom.” [ Al-Bayhaqi.]
5- Ability

It is the possession of provisions[ Az-Zaad: Basic necessities, such as food, drink and clothing.] and a means of transportation,[ Ar-Rahilah: Means of transport, e.g. a car, plane or ship.] as Allah the Most High said: “And Hajj is a duty that mankind owes Allah, those who can afford the expenses...” (Al ‘Imran; 97)
6- Presence of a Mahram[ Al-Mahram: An unmarriable relative of a woman e.g. the father, brother, uncle, etc.] with a woman

Due to the hadeeth of Ibn ‘Abbas t: I heard the Prophet ﷺ say while delivering a sermon: “A woman must not travel except with a male unmarriable relative.” Upon that a man stood and said: “Indeed, my wife has gone out on pilgrimage and I have been enlisted to fight in such and such a battle.” The Prophet ﷺ replied: “Go and perform Hajj with your wife.” [ Agreed upon.]

source

Rulings Regarding Hajj and Umrah - al-feqh.com