diff --git a/swh/core/db/tests/db_testing.py b/swh/core/db/tests/db_testing.py
index 3c8c34d6ccfe9471c9ebb8a01237a89e4a946ea4..89bd2342df839b904c31c1fc743a2ffceffbb90e 100644
--- a/swh/core/db/tests/db_testing.py
+++ b/swh/core/db/tests/db_testing.py
@@ -42,7 +42,11 @@ def swh_db_version(dbname_or_service):
 
     try:
         r = subprocess.run(
-            cmd, check=True, stdout=subprocess.PIPE, universal_newlines=True
+            cmd,
+            check=True,
+            stdout=subprocess.PIPE,
+            stderr=subprocess.PIPE,
+            universal_newlines=True,
         )
         result = int(r.stdout.strip())
     except Exception:  # db not initialized