CNBC's Jim Cramer warned stock investors Wednesday to pay attention to the possible recession signal coming from the bond market.

"I have learned to never fight the bond market, even when it's wrong," Cramer said on "Squawk on the Street." "Nobody is willing to ever say, 'the bond market is wrong.'"

Cramer acknowledges the U.S. economy appears to be slowing but feels there's not enough evidence to point to a recession, which is technically defined as two straight quarters of contraction in the economy.

"If interest rates would just go, it's amazing I have to say this, if interest rates would go up a little the [stock] market would like it," Cramer said. "I can't recall in my career rooting for higher interest rates. That is nuts."

The Dow Jones Industrial Average at one point fell more than 300 points Wednesday, tracking closely the decline in yields, which investors were taking as a message from the bond market that a slowing in the economy was ahead.

As U.S.-China trade war fears continue to intensify against the backdrop of some softer economic data, investors this month have been seeking safety and buying Treasurys, sending government debt prices soaring and yields plummeting to multiyear lows. Bond prices and yields move inversely to one another. The decline in yields has been more precipitous on longer-term bonds, pushing the 10-year Treasury rate below that of the 3-month government note.

That so-called yield curve inversion on the 10-year and the 3-month — recently widening to spreads not since the 2008 financial crisis — has been viewed on Wall Street as a sign of a recession on the horizon.

The stock market has been following Treasury yields lower, and as of Tuesday's close the was off nearly 5% for the month of May. The index opened sharply lower on Wednesday, with no resolution in sight to the trade and technology disputes between the U.S. and China, which have led to billions and billions of dollars worth of sanctions on each others' goods.

— CNBC's Jessica Bursztynsky contributed to this report.