diff --git a/core/modules/file/file.install b/core/modules/file/file.install
index a975eed34b43a611e49deed6262df3243b5a88d5..e2e4ce61a7c7b2b9fd73c2c6bdd0cc6a64d8d60d 100644
--- a/core/modules/file/file.install
+++ b/core/modules/file/file.install
@@ -69,7 +69,9 @@ function file_requirements($phase) {
   if ($phase == 'runtime') {
     $description = NULL;
     $implementation = file_progress_implementation();
-    $server_software = \Drupal::request()->server->get('SERVER_SOFTWARE');
+    // The environment variable might be missing. Fallback to an empty string to
+    // prevent passing NULL to preg_match(), a few lines later.
+    $server_software = \Drupal::request()->server->get('SERVER_SOFTWARE', '');
 
     // Test the web server identity.
     if (preg_match("/Nginx/i", $server_software)) {