Skip to content

Commit

Permalink
If ServerApp.ip is ipv6 use [::1] as local_url
Browse files Browse the repository at this point in the history
  • Loading branch information
manics committed Jan 26, 2025
1 parent dd7daf9 commit 6880f01
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion jupyter_server/serverapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2377,7 +2377,11 @@ def local_url(self) -> str:
parts = self._get_urlparts(include_token=True)
# Update with custom pieces.
if not self.sock:
parts = parts._replace(netloc=f"127.0.0.1:{self.port}")
if ":" in self.ip:
localhost = "[::1]"
else:
localhost = "127.0.0.1"
parts = parts._replace(netloc=f"{localhost}:{self.port}")
return parts.geturl()

@property
Expand Down

0 comments on commit 6880f01

Please sign in to comment.