Skip to content

With mkdocs serve switch to another port if the current port is busy #3496

Open
@fralau

Description

@fralau

It is possible that a couple of instances of the MkDocs web server are running at the same time, for legitimate reasons. The second time, the server won't start, unless a different port is used. The solution is to use the -a/--dev-addr option with mkdocs-server, but it is tedious.

Programmatically checking that the port is free is easy, and this could be automated (rather than failing).

Additional points

  1. For the port numbers, a simple approach would be to increment the port from 8000 up, let's say on a range from 8000 to 8019 (I do not see why one would want to open more than a couple; it would rapidly become difficult for the user to keep up with their own mind pointers/terminal sessions).
  2. Needless to say, a server that self-updates (after detecting a file change) should keep the same port.

See also discussion in #3494

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions