Success in international trade depends, amongst other things, on distance from markets. Most new economic geography models focus on the distance between countries. In contrast much less theorizing and empirical analysis have focused on how distances within a country for instance due to the location behaviour of exporting firms matter to international trade. In this paper we contribute to the literature on the latter by offering a theoretical model to explain the optimal distance that an export-oriented firm would locate from a port. We present empirical evidence from South Africa in support of the model.