diff --git a/core/includes/batch.inc b/core/includes/batch.inc
index 90001eb23b..d1951c390a 100644
--- a/core/includes/batch.inc
+++ b/core/includes/batch.inc
@@ -22,6 +22,7 @@
 use Symfony\Component\HttpFoundation\JsonResponse;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpFoundation\RedirectResponse;
+use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
 
 /**
  * Renders the batch processing page based on the current state of the batch.
@@ -42,8 +43,8 @@ function _batch_page(Request $request) {
   if (!$batch) {
     $batch = \Drupal::service('batch.storage')->load($request_id);
     if (!$batch) {
-      \Drupal::messenger()->addError(t('No active batch.'));
-      return new RedirectResponse(Url::fromRoute('<front>', [], ['absolute' => TRUE])->toString());
+      \Drupal::messenger()->addError(t('The requested batch (@batch) could not be found.', ['@batch' => $request_id]));
+      throw new NotFoundHttpException(sprintf('The requested batch %s could not be found.', $request_id));
     }
   }
 
diff --git a/core/tests/Drupal/FunctionalTests/Core/Batch/BatchNotFoundTest.php b/core/tests/Drupal/FunctionalTests/Core/Batch/BatchNotFoundTest.php
new file mode 100644
index 0000000000..4f4f8d9482
--- /dev/null
+++ b/core/tests/Drupal/FunctionalTests/Core/Batch/BatchNotFoundTest.php
@@ -0,0 +1,40 @@
+<?php
+
+namespace Drupal\FunctionalTests\Core\Batch;
+
+use Drupal\Tests\BrowserTestBase;
+
+/**
+ * Tests if Drupal returns page not found error when batch ID does not exist.
+ *
+ * @group Batch
+ */
+class BatchNotFoundTest extends BrowserTestBase {
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = ['batch_test'];
+
+  /**
+   * Tests for page not found error if batch ID does not exist.
+   */
+  public function testBatchNotFound() {
+    $edit = ['batch' => 'batch_0'];
+    $this->drupalPostForm('batch-test', $edit, 'Submit');
+
+    $batch_id = $this->container->get('database')->nextId();
+
+    $this->drupalGet('batch', [
+      'query' => [
+        'op' => 'start',
+        'id' => $batch_id,
+      ],
+    ]);
+
+    $this->assertSession()->statusCodeEquals(404);
+  }
+
+}
