title_body: What is the right coffee ground size for an espresso coffee machine?
upvoted_answer: Practically speaking, an arbitrary number can only get you so far. What you need to focus on is what we would call 'dialling in'. This is a term to describe the process by which we find the most suitable parameters for making the 'best' cup of coffee. 'Dialling in' can mean a multitude of things but in your case it will simply refer to finding the right grind size and/or dosage.
  
  The problem you seem to have is directly because you are shooting far above and below the the 'right' grind size assuming that you are using the exact same mass of coffee every time.
  
  To find the right grind size, you must have a decent enough grinder that grinds to a uniform level and can be adjusted to a high degree, you should only be adjusting in small amounts. If you do not have a grinder, it will be very hard if not impossible to find a pre-ground bag that works perfectly for you. If you are choking the machine because the particle size is too small, adjust coarser gradually and keep making shots to observe the change in extraction times and flavours. If you are extracting very fast and water is rushing out causing under-extraction, adjust finer. Repeat until you achieve the 'best' flavour you can.
  
  At this point, if your coffee still tastes off then your problem may lie in your dosage. You may be using too much or too little coffee causing hindrance to a uniform extraction. Once again, simply adjusting your dosage above and below your current amount in small increments will help you find the spot where the extraction performs the best.
  
  If your coffee still tastes off you may be having temperature stability issues, water quality issues, coffee freshness issues, unstable brew-head pressure issues, poor basket distribution and tamping or any combination of the above.
  
  Since the 'right' grind size for espresso, or any brew method for that matter, is never the same and is dependent on, at the very least, the coffee bean itself which is still a variable even if brewing from the same bag, finding the 'right' grind size is always going to be a chase and 'dialling in' will be an exercise you will almost always have to do if you want the best coffee you can extract from what you have.
  
  MT San's answer provides a link to a more generic explanation and reference to the different general grind sizes for the different brew methods if you are completely in the dark.