Reflex Chess

Every reason castling is not allowed

Castling has more conditions attached to it than any other move in chess, and three of them involve check in ways that sound identical and are not. Every position on this page was put to a real chess engine.

Short version, then the detail. You cannot castle out of check, through check or into check. You can castle when the rook is attacked, and you can castle when the square the rook passes over is attacked. Those last two are the ones almost everybody gets wrong.

Out of check: no

In check, so no castling at all

abcdefgh12345678

The bishop on b4 checks the white king along the b4 to e1 diagonal. Ask the engine for White's legal moves and there are four of them: three king steps and a pawn to c3 that blocks. Neither castle is on the list.

This one is absolute. It does not matter which side, it does not matter whether the king would be safe afterwards, and it does not matter that castling would block the check. While you are in check, castling is not a legal move.

You can still castle later. Deal with the check by blocking it or by capturing the checking piece, and the right survives. It is only moving the king that destroys it for good.

Through check: also no

One attacked square, one castle lost

abcdefgh12345678

The bishop on a6 attacks f1, which is the square the white king would cross on his way to g1. Kingside castling is illegal. Queenside is fine, and the engine lists O-O-O among White's legal moves.

The king may not pass through an attacked square, so a single piece aimed at f1 or d1 takes that castle away without ever giving check. This is the condition that decides real games: an enemy bishop on the a6 to f1 diagonal is a standing threat to your king safety even though it is attacking nothing you can lose.

Into check: no, obviously

The landing square is covered

abcdefgh12345678

The rook on g8 owns the open g-file, so g1 is attacked and kingside castling is illegal. Queenside is still available.

This is really just the ordinary rule that a king may not move into check, applied to the square he lands on. Worth stating separately only because the three conditions get quoted as a set.

The rook being attacked does not matter

Attacked rook, legal castle

abcdefgh12345678

The black rook on b8 attacks b1, the square White's rook passes over during queenside castling, and it attacks the a1 rook itself. O-O-O is still legal, and the engine confirms it.

The check conditions apply to the king and only the king. The rook may be attacked, may pass over an attacked square, and may land on an attacked square, and castling remains legal in every one of those cases. This is the single most commonly misremembered rule in chess and it comes up constantly in queenside castling, where b1 and b8 are often covered by a rook on a half-open b-file.

The king went for a walk and came back

Castling rights are not restored. Once your king has moved, even one square and even straight back to e1, both castles are gone for the rest of the game. The engine agrees: from the position at the top of the castling page, play the king to f1 and back to e1 while Black does the same, and castling kingside is no longer among White's legal moves.

The same is true rook by rook. Move the h1 rook to g1 and back, and kingside castling is dead while queenside is untouched.

The full checklist

Questions people ask

Can you castle out of check?

No. Castling while your king is in check is illegal, on both sides, with no exceptions. Get out of the check some other way first. If you can block it or capture the checking piece rather than moving your king, your castling rights survive and you can castle on a later move.

Can you castle through check?

No. The king may not cross a square that an enemy piece attacks. If a single bishop is aimed at f1, kingside castling is off, even though the king is not in check now and would not be in check afterwards.

Can you castle if the rook is attacked?

Yes. All three of the check conditions apply to the king alone. The rook may be under attack, may pass over an attacked square, and may land on one. This comes up most often with queenside castling when an enemy rook owns the b-file.

Can you castle out of check by blocking with the rook?

No. It makes no difference that the rook would end up blocking the check. Castling out of check is illegal because of the position the king is in when the move begins, not because of what the move achieves.

Does moving the king and moving it back restore castling?

No. The right is lost permanently the moment the king moves, and there is nothing that brings it back. The same goes for each rook individually.

Related

When you cannot castle sits under The special moves in the reference. Nearby: