NEW YORK - Stocks keep reaching new heights, and investors keep giving them the side eye.

Even as the Standard & Poor’s 500 index was setting a string of records through July, nearly as many dollars were leaving stock funds as entering. Investors are still skeptical of a market that hurt them so painfully during the 2008 financial crisis.

The hesitancy isn’t surprising, even seven-plus years after stocks began one of their longest-ever runs, given the long list of worries hanging over the market. Chief among them is that companies’ stock prices have risen more quickly than their profits, leading to worries that stocks are too expensive. Economic growth around the world also remains slow, and companies are having a tough time drumming up more sales. The wild, down-and-up ride that stocks have been on for the last year hasn’t helped either.

Get Breaking News Delivered to Your Inbox

Some analysts see this as an encouraging signal. If the S&P 500 can climb to record highs now, when investors are largely snubbing stocks, it could rise even higher when or if strong demand returns. Many strategists along Wall Street are forecasting continued modest gains for stocks, largely because they see an imminent recession as unlikely.

Some types of stock funds are still drawing interest: those that simply track the S&P 500 and other indexes. These mutual funds and exchange-traded funds charge much lower fees than ones run by stock pickers trying to beat the market. They’ve also been the better performers in recent years. Only one out of three large-cap fund managers was able to beat the S&P 500 in 2015, and the last time a majority of them did so was in 2007, according to S&P Dow Jones Indices.

The SPDR S&P 500 ETF attracted a shade over $11 billion in net investment in July, for example, its biggest month since December 2014, according to Morningstar. As a group, funds tracking U.S. stock indexes pulled in $33.8 billion last month.

But the dollars flowing into index funds are merely helping to offset the dollars leaving actively managed stock funds. Fund investors aren’t building up their overall investments in the U.S. stock market. Nearly $33 billion left actively managed U.S. stock funds in July. And over the last 12 months, $47 billion more has departed them than entered into index funds.

The exit from stock funds doesn’t seem to be just a case of selling high after buying low. Investors have largely been pulling out of stock funds since the start of 2015.

What are they turning to instead? Bonds and other investments that are traditionally seen as offering a “safer” ride.

Nearly $163 billion poured into bond mutual funds and ETFs in the first seven months of the year. A quarter of that came in July alone, the same month when the S&P 500 and other stock indexes were setting records.

Interest rates are still low, which means that bonds are producing relatively low amounts of income. But prices for bonds rise when rates fall, and the weak global economy has been keeping a lid on rates.

Bond funds have also provided a steadier ride for investors this year than stocks. The worst week this year for the largest bond fund by assets was a 0.9 percent loss, which occurred in mid-July. The largest stock fund, meanwhile, had a loss more than six times that during the first week of the year.

Bond funds face a big threat of their own. If interest rates rise, it would drag down prices for bonds in funds’ portfolios and could leave investors with losses. In 2013, a temporary rise in rates sent the average intermediate-term bond fund to a loss of 1.4 percent for the year, for example.

For the moment, though, investors seem to be more willing to take on that risk than wade back into a stock market that has veered up and down on everything from worries about China’s economic growth to the United Kingdom’s pending exit from the European Union.

“Decent returns and the promise of a steady stream of income at a risk level that still allows you to sleep at night add up to an investment proposition that is hard to beat,” Morningstar senior analyst Alina Lamy wrote in a recent report.