The DMV renewal page states that online renewal is available up to 180 days before expiration, but it lists several situations that require in-person or mail renewal.
You cannot renew online if you did not get a new photo at your last renewal, if you are applying for a REAL ID license for the first time, if you are active-duty military or recently honorably discharged and want a no-fee renewal, if you are not a U.S. citizen, or if you hold a commercial driver license. Online renewal is also not available if your license is suspended, if your license has been expired for two or more years, if you have a drive-only license, if you have an S, V, A, or F endorsement, or if you do not have a first name on record or need a name update.
If any of those apply, schedule an appointment or renew by mail if eligible. Address changes can be completed online at least one week prior to renewal.