Yes en passant only works when you pawn is on the 5th rank--it means in passing and the pawn is passing through a square would you had the opportunity to take it if it had only moved one square.
For example if you pawn was still on f5 and Black played...g5 it passed through g6 which you pawn controls--here at f6 you could have taken the Black pawn at g7
I was unable to take black pawn at g5 with En Passant. Can someone please explain reason? I still won the game, but need to know this for my future games.