Consistent Local Ports with Wrangler

Published See discussion on Twitter

For the life of me I couldn't find any documentation on Cloudflare's Worker Docs nor the Wrangler CLI GitHub Repo about this, so I figured I should write a quick blog post to help out others (or mainly myself if I ever forget this)!

TL;DR:

Pass the --port <num> argument when running wrangler dev!

You can provide a --port CLI argument to the wrangler dev command to configure the port that the service starts on locally.

This can be useful for testing the service locally (either manually or via some sort of automation) to ensure that it's always started on the same port instead of a new one each time the service is started.


Edit! I finally found it documented, but took a while to track it down in their docs here.