Swift development tips and experiences by Tommi Kivimäki

Browse all notes

How to set a port number for Vapor server on localhost

Vapor defaults to port 8080 on localhost. I couldn’t use the 8080, since that was reserved for another server on my MacBook Pro. Here’s how I set a different port number from the command line.

swift run Run --hostname localhost --port 9000

This works with Vapor Framework 3.0.8 and Toolbox 3.1.10 and probably with many other versions too. This command also runs the app, so there’s no need to open the Xcode.