One form resolving and the other not.
THE CAUSE
A missing record for one of them.
Both need to resolve: the bare domain and www.
WHAT SHOULD EXIST
An A record for the bare domain, pointing at your server An A record or CNAME for www
A CNAME for www pointing at the bare domain is common and works well.
IF THE BARE DOMAIN FAILS
Check an A record exists for it. Some providers label this the root, the apex, or an empty name.
IF WWW FAILS
Check a record exists for www specifically. It is not automatic.
THE REDIRECT QUESTION
Separate from resolution. Both must resolve; then a redirect sends one to the other.
If neither resolves, no redirect helps.
THE APPLICATION SETTING
Your site's configured address determines which form it uses. A mismatch between that and the address a visitor uses produces cookie and login problems.
Pick one form, redirect the other, and set the application to match.
CHECKING
Look up both. Both should return an address.