user3149: Here is a picture of the starting position. White to move.
[FEN "8/8/8/3nk1pp/8/3K2PP/5P2/8 w - - 0 1"]

1. f3 h4 2. f4+ gxf4 3.gxf4+ Kxf4 4. Ke2 Kg3 5. Kf1 Kxh3 6. Kg1 Kg3

1. f3 h4
2. f4+ gxf4 (to make it into king and knight + rook pawn endgame which is drawn)
3.gxf4+ Kxf4 
4. Ke2 (to reach the g1 and h1 squares to draw)
4... Kg3 
5. Kf1 Kxh3
6. Kg1 Kg3
I forgot the rest of the moves, but somehow it's losing for white. I thought a king and knight + rook pawn is always drawn if the opponent's king can reach the g1 h1 squares. Why didn't it work this time and when are these endgames drawn? 

user9423: You're confusing this theoretical endgame with K+B+P vs K. 
If the bishop doesn't match the promotion square of a or h file that the pawn is on, then the pawn can not promote in your scenario.
On the other hand, the knight can go to any square on the board potentially so the h1 square can be covered by it.

I suggest going to the link below to understand how to force the king out of the corner. Ideally you should get this position with white to play, and check to force Kg8 and push the pawn.

http://www.chesskit.com/training/endgame/KNPk/1/index.php

3149: <p>Here is a picture of the starting position. White to move.</p>

<pre><code>[FEN "8/8/8/3nk1pp/8/3K2PP/5P2/8 w - - 0 1"]

1. f3 h4 2. f4+ gxf4 3.gxf4+ Kxf4 4. Ke2 Kg3 5. Kf1 Kxh3 6. Kg1 Kg3
</code></pre>

<p><strong>1. f3 h4</strong></p>

<p><strong>2. f4+ gxf4</strong> (to make it into king and knight + rook pawn endgame which is drawn)</p>

<p><strong>3.gxf4+ Kxf4</strong> </p>

<p><strong>4. Ke2</strong> (to reach the g1 and h1 squares to draw)</p>

<p><strong>4... Kg3</strong> </p>

<p><strong>5. Kf1 Kxh3</strong></p>

<p><strong>6. Kg1 Kg3</strong></p>

<p>I forgot the rest of the moves, but somehow it's losing for white. I thought a king and knight + rook pawn is always drawn if the opponent's king can reach the g1 h1 squares. Why didn't it work this time and when are these endgames drawn? </p>
 9423: <p>You're confusing this theoretical endgame with K+B+P vs K. </p>

<p>If the bishop doesn't match the promotion square of a or h file that the pawn is on, then the pawn can not promote in your scenario.</p>

<p>On the other hand, the knight can go to any square on the board potentially so the h1 square can be covered by it.</p>

<p><a href="https://i.stack.imgur.com/nxog4.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/nxog4.gif" alt="enter image description here"></a></p>

<p>I suggest going to the link below to understand how to force the king out of the corner. Ideally you should get this position with white to play, and check to force Kg8 and push the pawn.</p>

<p><a href="https://i.stack.imgur.com/3AHw3.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/3AHw3.jpg" alt="enter image description here"></a></p>

<p><a href="http://www.chesskit.com/training/endgame/KNPk/1/index.php" rel="noreferrer">http://www.chesskit.com/training/endgame/KNPk/1/index.php</a></p>
