diff --git a/src/libstore/download.cc b/src/libstore/download.cc
index cf3929cadd6551c6c2f5a6dbae5ccc5b9aa83093..ce5584188a1226390c48ef20fe97c0ad6dc7cffe 100644
--- a/src/libstore/download.cc
+++ b/src/libstore/download.cc
@@ -195,8 +195,12 @@ struct CurlDownloader : public Downloader
             Error err =
                 httpStatus == 404 ? NotFound :
                 httpStatus == 403 ? Forbidden : Misc;
-            throw DownloadError(err, format("unable to download ‘%1%’: %2% (%3%)")
-                % url % curl_easy_strerror(res) % res);
+            if (res == CURLE_HTTP_RETURNED_ERROR && httpStatus != -1)
+                throw DownloadError(err, format("unable to download ‘%s’: HTTP error %d")
+                    % url % httpStatus);
+            else
+                throw DownloadError(err, format("unable to download ‘%s’: %s (%d)")
+                    % url % curl_easy_strerror(res) % res);
         }
 
         if (httpStatus == 304) return false;