AspNetCore.HealthChecks.NpgSql 8.0.1

dotnet add package AspNetCore.HealthChecks.NpgSql --version 8.0.1                
NuGet\Install-Package AspNetCore.HealthChecks.NpgSql -Version 8.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AspNetCore.HealthChecks.NpgSql" Version="8.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AspNetCore.HealthChecks.NpgSql --version 8.0.1                
#r "nuget: AspNetCore.HealthChecks.NpgSql, 8.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AspNetCore.HealthChecks.NpgSql as a Cake Addin
#addin nuget:?package=AspNetCore.HealthChecks.NpgSql&version=8.0.1

// Install AspNetCore.HealthChecks.NpgSql as a Cake Tool
#tool nuget:?package=AspNetCore.HealthChecks.NpgSql&version=8.0.1                

PostgreSQL Health Check

This health check verifies the ability to communicate with PostgreSQL. It uses the Npgsql library.


Starting with Npgsql 7.0 (and .NET 7), the starting point for any database operation is NpgsqlDataSource. The data source represents your PostgreSQL database, and can hand out connections to it, or support direct execution of SQL against it. The data source encapsulates the various Npgsql configuration needed to connect to PostgreSQL, as well as the connection pooling which makes Npgsql efficient.

Npgsql's data source supports additional configuration beyond the connection string, such as logging, advanced authentication options, type mapping management, and more.

To take advantage of the performance NpgsqlDataSource has to offer, it should be used as a singleton. Otherwise, the app might end up with having multiple data source instances, all of which would have their own connection pools. This can lead to resources exhaustion and major performance issues (Example: #1993).

We encourage you to use Npgsql.DependencyInjection package for registering a singleton factory for NpgsqlDataSource. It allows easy configuration of your Npgsql connections and registers the appropriate services in your DI container.

To make the shift to NpgsqlDataSource as easy as possible, the Npgsql.DependencyInjection package registers not just a factory for the data source, but also factory for NpgsqlConnection (and even DbConnection). So, your app does not need to suddenly start using NpgsqlDataSource everywhere.

void Configure(IServiceCollection services)

By default, the NpgsqlDataSource instance is resolved from service provider. If you need to access more than one PostgreSQL database, you can use keyed DI services to achieve that:

void Configure(IServiceCollection services)
    services.AddNpgsqlDataSource("Host=pg_server;Username=test;Password=test;Database=first", serviceKey: "first");
    services.AddHealthChecks().AddNpgSql(sp => sp.GetRequiredKeyedService<NpgsqlDataSource>("first"));

    services.AddNpgsqlDataSource("Host=pg_server;Username=test;Password=test;Database=second", serviceKey: "second");
    services.AddHealthChecks().AddNpgSql(sp => sp.GetRequiredKeyedService<NpgsqlDataSource>("second"));

Connection String

Raw connection string is of course still supported:

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (47)

Showing the top 5 NuGet packages that depend on AspNetCore.HealthChecks.NpgSql:

Package Downloads

Package Description


A PostgreSQL® client that integrates with Aspire, including health checks, metrics, logging, and telemetry.


The package with UI for the administration of the IdentityServer4


Package Description


The package with UI for the administration of the Duende IdentityServer

GitHub repositories (15)

Showing the top 5 popular GitHub repositories that depend on AspNetCore.HealthChecks.NpgSql:

Repository Stars
The administration for the IdentityServer4 and Asp.Net Core Identity
An opinionated, cloud ready stack for building observable, production ready, distributed applications in .NET
OSharp是一个基于.Net6.0的快速开发框架,框架对 AspNetCore 的配置、依赖注入、日志、缓存、实体框架、Mvc(WebApi)、身份认证、功能权限、数据权限等模块进行更高一级的自动化封装,并规范了一套业务实现的代码结构与操作流程,使 .Net 框架更易于应用到实际项目开发中。
Microservices on .Net platforms which used ASP.NET Web API, Docker, RabbitMQ, MassTransit, Grpc, Yarp API Gateway, PostgreSQL, Redis, SQLite, SqlServer, Marten, Entity Framework Core, CQRS, MediatR, DDD, Vertical and Clean Architecture implementation with using latest features of .NET 8 and C# 12
A microservices e-commerce reference application built with ASP.NET 6
Version Downloads Last updated
8.0.1 938,223 4/2/2024
8.0.0 948,667 12/15/2023
7.1.0 993,180 10/3/2023
7.0.0 748,978 7/30/2023
7.0.0-rc2.7 62,074 3/13/2023
7.0.0-rc2.6 36,847 1/14/2023
7.0.0-rc2.5 23,594 12/27/2022
7.0.0-rc2.4 397 12/27/2022
6.0.2 8,672,967 2/28/2022
6.0.1 877,437 12/29/2021
6.0.1-rc2.3 34,568 11/10/2021
6.0.1-rc1.2 2,299 11/5/2021
6.0.0 75,602 12/29/2021
5.0.2 3,032,690 3/8/2021
5.0.1 465,531 1/5/2021
5.0.0 30,800 12/29/2020
5.0.0-preview1 9,231 11/22/2020
3.1.1 3,021,488 4/17/2020
3.1.0 367,864 4/9/2020
3.0.0 851,733 9/24/2019
2.2.1 478,624 6/6/2019
2.2.0 370,157 11/14/2018