As I have understood from reading stuff on the internet and talking to people, too little sleep can have very serious health problems and you need to sleep at least 6 hours every night. what I don't know is if there is an upper limit to the the amount of sleep you get. Can sleeping too much also have detrimental health effects? What is the maximum amount that someone should be having every night?
People who sleep less than 6 hours and people who sleep more than 9 hours have been found to have a greater risk of suffering from adverse health effects, see e.g. here. But one cannot conclude from such observed correlations that changing sleeping behavior will help, this requires one to analyze the cause of these correlations. The way long sleep is associated with increased mortality is not well understood, as mentioned in this article:
It is therefore possible that long duration of sleep might be a consequence of, rather than a causative risk factor for, unrecognized chronic comorbidity, which in turn could explain the higher risk of mortality, particularly mortality from noncardiovascular causes, observed in many studies (1–4). Long sleep duration might represent a useful diagnostic tool for detecting other subclinical or undiagnosed mental or physical comorbidity (13).
For the causes of mortality with short and long sleep, the first linked article in @CountIblis' answer (Gallicchio & Kalesan, 2009) states that
The specific mechanisms underlying the association between sleep duration and mortality are unclear.
For short sleep (generally shorter than 7 hours)
A number of experimental studies have shown that short sleep causes potentially adverse endocrinologic, immunologic, and metabolic effects (Akerstedt and Nilsson, 2003; Knutson et al., 2007; Spiegel et al., 2005). For example, Spiegel et al. (2005) showed in a laboratory-based study that restricted sleep among 11 healthy men was associated with impaired glucose tolerance, higher evening cortisol levels, alterations in sympathetic nervous system activity, and a reduction in leptin secretion.
For long sleep (generally longer than 9 hours)
Unlike short sleep, long sleep has not consistently been shown to be associated with certain adverse medical conditions such as diabetes and hypertension, although studies have reported that long sleep is associated with obesity and stroke (Chen et al., 2008; Marshall et al., 2008). Further, adjustment for health conditions in studies examining the association between long sleep and mortality has not resulted in an attenuation of the association.
Åkerstedt, T., & Nilsson, P. M. (2003). Sleep as restitution: an introduction. Journal of internal medicine, 254(1), 6-12. https://doi.org/10.1046/j.1365-2796.2003.01195.x
Chen, J. C., Brunner, R. L., Ren, H., Wassertheil-Smoller, S., Larson, J. C., Levine, D. W., ... & Stefanick, M. L. (2008). Sleep duration and risk of ischemic stroke in postmenopausal women. Stroke, 39(12), 3185-3192. https://doi.org/10.1161/STROKEAHA.108.521773
Gallicchio, L., & Kalesan, B. (2009). Sleep duration and mortality: a systematic review and meta‐analysis. Journal of sleep research, 18(2), 148-158. https://doi.org/10.1111/j.1365-2869.2008.00732.x
Knutson, K. L., Spiegel, K., Penev, P., & Van Cauter, E. (2007). The metabolic consequences of sleep deprivation. Sleep medicine reviews, 11(3), 163-178. https://doi.org/10.1016/j.smrv.2007.01.002
Marshall, N. S., Glozier, N., & Grunstein, R. R. (2008). Is sleep duration related to obesity? A critical review of the epidemiological evidence. Sleep medicine reviews, 12(4), 289-298. https://doi.org/10.1016/j.smrv.2008.03.001
Spiegel, K., Leproult, R. and Van Cauter, E. Metabolic and endocrine changes. In: C. Kushida (Ed.) (2005) Sleep deprivation: basic science, physiology and behavior. New York: Marcel Dekker. 293–318.