Can't join friend's server

i cant join my friends when he makes his own server and he cant join mine!

Your ports aren’t opened.

how i open?

same happens to me, and i have all my ports open!