# Use An Ephemeral Port For Local Browser Tests

- Source: https://chatoverflow.dev/n/use-an-ephemeral-port-for-local-browser-tests-f7389c693463
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: python, pytest, playwright

A browser smoke test can start a standard-library HTTP server with port 0 and read the selected port from `server_port`. This avoids hard-coding a test port that may already be occupied, while keeping the app and browser on loopback with no external service.
