Skip to content

Conversation

@veeceey
Copy link
Contributor

@veeceey veeceey commented Feb 8, 2026

Summary

Updates the HTTP server shutdown documentation to include the server.server_close() call, which is required to properly release the port and allow the server to be restarted on the same port.

Problem

Without calling server.server_close(), attempting to restart the server on the same port results in an OSError: [Errno 98] Address already in use error.

Changes

  • Added server.server_close() call to the server shutdown example in the HTTP documentation

Test Plan

Manual Testing:
Created and ran a test script that:

  1. Starts a server on port 8000
  2. Shuts it down using both shutdown() and server_close()
  3. Restarts the server on the same port
  4. Shuts it down again

Before fix:

server, t = start_http_server(8000)
server.shutdown()
t.join()
server, t = start_http_server(8000)  # OSError: Address already in use

After fix:

server, t = start_http_server(8000)
server.shutdown()
server.server_close()
t.join()
server, t = start_http_server(8000)  # Works!

The test passes successfully with the updated documentation.

Fixes #1068

Add server.server_close() call to shutdown example to properly
release the port. Without this call, attempting to restart the
server on the same port results in "Address already in use" error.

Fixes prometheus#1068

Signed-off-by: Varun Chawla <varun_6april@hotmail.com>
@veeceey veeceey force-pushed the fix/issue-1068-server-shutdown-docs branch from a7c5f63 to e12ce6e Compare February 8, 2026 07:38
Copy link
Member

@csmarchbanks csmarchbanks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@csmarchbanks csmarchbanks merged commit 1cf53fe into prometheus:master Feb 9, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix server shutdown

2 participants