Hi there, thanks for the question.
This is because the fuel tank is not venting properly. So the it won't accept gas or the pressure in the tank will cause gas to spew out when trying to fill.
There is 3 valves in MOST THESE SYSTEMS, a vent valve, a vapor cut valve, and a purge solenoid.
More common than not when there is an issue with the vent valve not opening it will throw a code, so without a fault your primary concerns would be to loo at the vapor cut valve first mounted at the fuel tank.