Check Engine Light

My 2002 Subaru Forester has been having a problem with the check engine light coming on as soon as the gas gauge gets down to half full and when I fill up it goes out.My mechanic did a diagnostic test and said it was an engine knock.

If the engine is knocking it will do so regardless of how much fuel is in the tank.

Are you using the correct grade of gasoline, as specified in the owner’s manual?

The symptoms sound like a fuel pump. You may want to get it pressure checked.

 That CEL (check engine light) is just a kid in class waving her hand trying to get you attention because she has the answer. You need to have the codes read. Some places will read them for FREE. Try Autozone or Advanced Auto Parts. Get the exact code not just their translation into English and post it back here. It likely will have a format like P1234.

did you take it to the mechanic when the CEL was on? or did you fill up, and then take it there?

the problem must be present (or at least its a whole lot easier to diagnose) to be fixed.

i would think the gas octane may be an issue, if you have switched lately. or the fuel pump may be suspect.

on second thought if the tank at half is a repeatable trigger, then the fuel filter IS most suspect with the fuel pump being #2.