There has to be a space port on one of the planets in that system. It can be the same planet or a different planet that belongs to you in the same system.
The exception is, if you have the Natural Merchant special trait, then you don't need any space ports.