Kerry made the remarks to reporters at the end of annual high-level talks between the US and China.
Afghanistan has plunged into political chaos in recent months over a disputed presidential election that has stirred ethnic tensions in the fragile country.
The US was working "very closely" with all stakeholders in Afghanistan, he added, and Afghan candidates should not raise expectations among their supporters.
He said candidates must show statesmanship and leadership at a critical time, and that the US hopes "very much" over the course of the next few days that a way forward can be found.
Asked about Israel's attacks on Gaza, Kerry also said the US supports completely Israel's right to defend itself. The US has been in touch with Israeli and Palestinian leaders to determine the way to a ceasefire, he said.
"It's a dangerous moment" in Israel and the Palestinian territories, and the US will do all it can to bring an end to violence, he added.
(Reporting By Leslie Wroughton, Writing by Megha Rajagopalan; Editing by Nick Macfie)