diff --git a/mercurial/ui.py b/mercurial/ui.py
index 83e571ea06a96090584de8e07696fe0c8f588e88_bWVyY3VyaWFsL3VpLnB5..6f0941f4a184aca9c4f5149b96ed1697a10d6ea7_bWVyY3VyaWFsL3VpLnB5 100644
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -1464,7 +1464,7 @@
             return default
         try:
             self._writemsg(self._fmsgerr, prompt or _('password: '),
-                           type='prompt')
+                           type='prompt', password=True)
             # disable getpass() only if explicitly specified. it's still valid
             # to interact with tty even if fin is not a tty.
             with self.timeblockedsection('stdio'):
diff --git a/tests/test-commandserver.t b/tests/test-commandserver.t
index 83e571ea06a96090584de8e07696fe0c8f588e88_dGVzdHMvdGVzdC1jb21tYW5kc2VydmVyLnQ=..6f0941f4a184aca9c4f5149b96ed1697a10d6ea7_dGVzdHMvdGVzdC1jb21tYW5kc2VydmVyLnQ= 100644
--- a/tests/test-commandserver.t
+++ b/tests/test-commandserver.t
@@ -762,7 +762,9 @@
   ... def prompt(server):
   ...     readchannel(server)
   ...     interactive = [b'--config', b'ui.interactive=True']
+  ...     runcommand(server, [b'debuggetpass'] + interactive,
+  ...                input=stringio(b'1234\n'))
   ...     runcommand(server, [b'debugprompt'] + interactive,
   ...                input=stringio(b'5678\n'))
   ...     runcommand(server, [b'debugpromptchoice'] + interactive,
   ...                input=stringio(b'n\n'))
@@ -765,7 +767,10 @@
   ...     runcommand(server, [b'debugprompt'] + interactive,
   ...                input=stringio(b'5678\n'))
   ...     runcommand(server, [b'debugpromptchoice'] + interactive,
   ...                input=stringio(b'n\n'))
+  *** runcommand debuggetpass --config ui.interactive=True
+  message: '\xa3DdataJpassword: Hpassword\xf5DtypeFprompt'
+  1234
   *** runcommand debugprompt --config ui.interactive=True
   message: '\xa3DdataGprompt:GdefaultAyDtypeFprompt'
    5678