Is the cable an old one. Could be the cables inside broken.
If the cable is new. Depending on what make it is, could be an issue with the Type C connector.
Also check the charging port on the phone to make sure its clean with no dirt or pocket lint. I sometimes use a plastic or wooden tooth pick to gently pick out any fluff that I cannot blow out