--- a/lisp/gnus/nntp.el
+++ b/lisp/gnus/nntp.el
@@ -1066,11 +1066,12 @@ deffoo nntp-open-server (server &optional defs connectionless)
       (setq defs (cons (list 'nntp-port-number (car defs)) (cdr defs))))
     (unless (assq 'nntp-address defs)
       (setq defs (append defs (list (list 'nntp-address server)))))
-    (nnoo-change-server 'nntp server defs)
-    (if connectionless
-	t
-      (or (nntp-find-connection nntp-server-buffer)
-	  (nntp-open-connection nntp-server-buffer)))))
+    (with-current-buffer nntp-server-buffer
+      (nnoo-change-server 'nntp server defs)
+      (if connectionless
+	  t
+	(or (nntp-find-connection nntp-server-buffer)
+	    (nntp-open-connection nntp-server-buffer))))))
 
 (deffoo nntp-close-server (&optional server)
   (nntp-possibly-change-group nil server t)
