diff --git a/build.sh b/build.sh
index 426c7a6ac..3dea7ace0 100755
--- a/build.sh
+++ b/build.sh
@@ -766,13 +766,14 @@ if [ $WITH_DEPS -gt 0 ]; then
     #------------------------------------------------------------------------------
     nlohmannjsonDirName=nlohmannjson
     nlohmannjsonSingleHeaderName=json.hpp
-    dep_nlohmannjson=("nlohmannjson_v${nlohmannjsonVersion}" "v1")
+    dep_nlohmannjson=("nlohmannjson_v${nlohmannjsonVersion}" "v2")
 
     if ! is_dependency_installed "${dep_nlohmannjson[@]}"; then
         daphne_msg "Get nlohmannjson version ${nlohmannjsonVersion}"
         mkdir -p "${installPrefix}/include/${nlohmannjsonDirName}"
         wget "https://github.com/nlohmann/json/releases/download/v$nlohmannjsonVersion/$nlohmannjsonSingleHeaderName" \
             -qO "${installPrefix}/include/${nlohmannjsonDirName}/${nlohmannjsonSingleHeaderName}"
+        patch -Np0 -i "${patchDir}/0007-nlohmannjson-replace-EOF.patch" -d "${installPrefix}/include/${nlohmannjsonDirName}"
         dependency_install_success "${dep_nlohmannjson[@]}"
     else
         daphne_msg "No need to download nlohmannjson again."
diff --git a/software-package-versions.txt b/software-package-versions.txt
index 9a4244fff..37682e766 100644
--- a/software-package-versions.txt
+++ b/software-package-versions.txt
@@ -24,7 +24,7 @@ cudaVersion=12.6.1
 eigenVersion=3.4.0
 grpcVersion=1.38.0
 hwlocVersion=2.9.3
-nlohmannjsonVersion=3.10.5
+nlohmannjsonVersion=3.11.3
 openBlasVersion=0.3.23
 openMPIVersion=4.1.5
 papiVersion=7.0.1
diff --git a/thirdparty/patches/0007-nlohmannjson-replace-EOF.patch b/thirdparty/patches/0007-nlohmannjson-replace-EOF.patch
new file mode 100644
index 000000000..ddbee69ea
--- /dev/null
+++ b/thirdparty/patches/0007-nlohmannjson-replace-EOF.patch
@@ -0,0 +1,20 @@
+--- json.hpp.orig	2024-09-24 17:26:47.850173669 +0200
++++ json.hpp	2024-09-24 17:27:40.874776913 +0200
+@@ -3624,7 +3624,7 @@
+ 
+     static constexpr int_type eof() noexcept
+     {
+-        return static_cast<int_type>(EOF);
++        return static_cast<int_type>(std::char_traits<char>::eof());
+     }
+ };
+ 
+@@ -3648,7 +3648,7 @@
+ 
+     static constexpr int_type eof() noexcept
+     {
+-        return static_cast<int_type>(EOF);
++        return static_cast<int_type>(std::char_traits<char>::eof());
+     }
+ };
+