I have 2007 Honda Accord, there was a check engine light for Knock sensor and wiring Harness, I replaced both of them, and it still says?

The same thing, what could it be next?

Check engine codes rarely give you just one single cause -- in the sense that replacing that part will fix the problem for sure. That's why a good/honest mechanic won't just randomly install new parts. There are ways of determining what exactly is going wrong.

Unloosen and tighten the gas cap and see if that fixes it. I know weird, but it works.

The code only tells you what parts or system are being effected not necessarily the part that is defective. Can be carbon buildup in the engine combustion chamber. Can be defective wiring or a bad ECU. You need to take it to a specialist and have it repaired.

That should be part of the 5 Volt Reference System. Check that the connector has 5V (not 4 or 6) and a Ground. But the Knock Sensor is one of the least necessary Sensors on a car. All it does is listen for Spark Knock and retards Ignition Timing when it hears it. Use Tier 1 Gas of the correct grade and don't let it run hotter than normal and clean Carbon from the Combustion Chambers and you will never have Spark Knock.