Tesla almost died earlier this year, CEO Elon Musk said in an interview with Axios that aired on HBO.

Musk said the company was "bleeding money like crazy" as it worked through the Model 3 production ramp in the spring and summer. He said the company "came within single-digit" weeks of death before it was able to meet its Model 3 production goals.

"Tesla really faced a severe threat of death due to the Model 3 production ramp," Musk said in the interview, which aired Sunday night. "Essentially, the company was bleeding money like crazy, and if we didn't solve these problems in a very short period of time, we would die. And it was extremely difficult to solve them."

Musk also talked about the personal toll working nonstop during the production ramp, calling it "very painful."

"It hurts my brain and my heart," Musk said. "It hurts. It is not recommended for anyone. I just did it because if I didn't do it ... there was a good chance Tesla would die."

Watch: How taxpayers have boosted Elon Musk and Tesla