The U.S. Geological Survey put the epicenter of the 4:49 a.m. temblor about 7 miles north of Cabazon.
There were no immediate reports of damage.
According to the USGS, the quake was felt across a wide swath of the region, from the Inland Empire west to Los Angeles and Orange County.
The quake was followed by several aftershocks.
Seismologist Lucy Jones said on Twitter that the temblor occurred in a “complex part” of the San Andreas fault under the San Bernardino Mountains and was not far from the epicenter of a 1986 quake that measured 5.9 magnitude.
This marks the second time in little more than a month that the region has been hit by a small quake felt over a large area.