Where I live, in Morocco, free mixing is normal during family gatherings and even with friends, and many imams there say that it is permissible, with no guidelines as far as how the women should be covered. Of course I completely disagree with this. How is one supposed to uphold family ties when it is always in a mixed environment? We can invite them to our house, where there would be no mixing, but they still want us to go to their house. Do we go to their house anyway, knowing that there will be much fitna (temptation), with free mixing and unveiled women? May Allah guide our ummah (community) to the straight path.
I just don’t see how one can avoid all of these problems, but I believe it is our duty to do so as much as possible. Basically, my question is, which one is the bigger priority, upholding family ties or avoiding an environment where there is free mixing; men speaking openly with women, who are also unveiled in most cases? Also, are we allowed to refuse an invitation if we know the environment will be as the one described above? Also, who is the family with whom we must uphold family ties? Does it include cousins (even if they are of the opposite sex), or only mahrams (close relatives to whom marriage is forbidden)?
It is good that you believe that it is one of our duties to do our best to avoid that haraam (impermissible) free mixing. Let us tell you that we do not object to upholding family ties at all; rather we promote and encourage that, because it is part of upholding the ties of kinship (silat al-rahm) that is enjoined upon us by Allah and His Messenger.
But more important than that, the questioner should understand that there is no contradiction between the two matters at all. It is possible to keep away from haraam free mixing and it is also possible to uphold ties of kinship. Islam enjoins both matters, so it is not possible for there to be any contradiction between them.
In that case, what you should do in your country is try to uphold the ties of kinship and avoid the free mixing that is widespread in your country. There are many people who have been able to do that and live their lives in a natural manner.
But it is important for the individual to have sufficient resolve and keenness to do that.
If when people visit you, you allocate one place for women to sit and another place for men, and you show your keenness to implement this segregation, then when you visit your relatives or other people, they may follow your wishes with regard to this segregation when they realize that you are very keen on that, no matter how small the house is.
With regard to chance meetings in the street and in the entry way to the house if it has only one entrance, and so on, this is something that is not forbidden in sharee‘ah (Islamic law) and the rulings on it are not strict; what is prescribed is to be cautious with regard to this matter so that it does not become the norm and a person should not do it if it is possible to avoid it.
Finally, you should note that attaining Paradise requires some effort, hard work and striving. Paradise is surrounded with difficult matters that people may find hard, but one needspatience in obeying his Lord, and that is the greatest kind of patience. The Messenger of Allah (blessings and peace of Allah be upon him) said: “Knowledge is only attained by striving to learn and patience is only attained by striving to be patient and the one who seeks good will be given it and the one who seeks to avoid evil will be protected from it.” Narrated by al-Tabaraani in al-Awsat, 2663; classed as hasan (sound) by al-Albaani.
See also the answer to question no. 12838
And Allah knows best.