Index: src/bp-groups/bp-groups-actions.php
===================================================================
--- src/bp-groups/bp-groups-actions.php
+++ src/bp-groups/bp-groups-actions.php
@@ -92,14 +92,27 @@
 		return;
 	}
 
-	// Groups that the user cannot know about should return a 404 for non-members.
-	// Unset the current group so that you're not redirected
-	// to the default group tab.
+	// Kill the page if group isn't visible and user does not have access.
 	if ( ! $is_visible ) {
-		buddypress()->groups->current_group = 0;
-		buddypress()->is_single_item        = false;
-		bp_do_404();
-		return;
+		// If user isn't logged in, show login form.
+		$login_form = '';
+		if ( ! is_user_logged_in() ) {
+			$login_form  = sprintf( '<p>%s</p>', esc_html__( 'If you are a member of this group, login to gain access.', 'buddypress' ) );
+			$login_form .= wp_login_form( array(
+				'echo'           => false,
+				'label_username' => esc_html__( 'Username', 'buddypress')
+			) );
+		}
+
+		wp_die(
+			sprintf( '<p>%1$s</p>%2$s', esc_html__( 'You do not have access to this group.', 'buddypress' ), $login_form ),
+			__( 'Unauthorized', 'buddypress' ),
+			array(
+				'response'  => 403,
+				'back_link' => true
+			)
+		);
+
 	} else {
 		bp_core_no_access( $no_access_args );
 	}
