There are a number of reasons why an engine would knock when you idle the vehicle. It could be your motor mounts. You may also need oil.
bums
Mine and everyone I have hears makes a knocking sound at idle, I wouldn't worry about it unless it does it through the whole rpm or is really lowed
maybe you need your computer reflashed. It worked for me.
Lifters or valves.
it sounds like you have a major problem if the engine knocking is coming from the oil pan that could be a rod knocking. that means having to pull engine and spend a lot of money. good luck you may need it.
Usually, a knocking engine is very bad, and requires replacement or rebuild of the engine. If the engine is going "clank-clank-clank" at idle, and the sound gets louder when you get on the gas and disappears for a sec or two when you let off, that means you gotta replace the engine. You ain't gonna go for but a couple more miles before you throw a rod....
knocking noise
Sorry, disregard this question, I didn't word it properly.
My 99 sonoma had a knock and it was a wrist pin in the engine, my 99 jimmy fuel injection leaked gas in the engine oil and caused the main bearings to fail because of lack of proper lubrication.
engine knocking hard,and shaking a bit
does it sound more like a knocking sound from the engine at idle?
I had the same problem when I cleaned and replaced my KN filter after 3 months of use. It was caused by too much oil on the filter element. It fowls the knocking sensor on the engine and causes the knocking noise at idle. I removed the filter and cleaned it. Then I very lightly oiled it and replaced it. The knocking went away in about a week. If it doesn't, you might have to replace the sensor. I'm not a mechanic... this is all the help I can give you. Good luck!