Solution:
Go to WordPress Admin → Settings → General and verify that:
WordPress Address (URL)
Site Address (URL)
are both set correctly.
A mismatch here (for example, one with www. and the other without) can often cause redirect loops or header-related errors.