{"Entry":{"collection":"conn","key":"hostaddr","name":"hostaddr","aliases":["PGHOSTADDR","hostaddr"],"metadata":{"aliases":["PGHOSTADDR","hostaddr"],"category":"Connection destination","content_hash":"921a909137ba93462076f785a3d56da01acf2b6e83555a1cc536cf0ef34aa0db","imported_at":"2026-09-30T00:40:34.901877+08:00","name":"hostaddr","name_zh":"","slug":"hostaddr","summary":"Numeric IP address of host to connect to. This should be in the standard IPv4 address format, e.g., 172.28.40.9 . If your machine supports IPv6, you can also use those addresses. TCP/IP communication is always used when a nonempty string is specified for this parameter. If this parameter is not specified, the value of host will be looked up to find the corresponding IP address — or, if host specifies an IP address, that value will be used directly."}},"Definition":{"Collection":"conn","Key":"hostaddr","SourceDatabase":"center","Version":"18","SourceTable":"connection_parameter","SourceKey":"hostaddr","SourceRevision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","Facts":{"comparison_data":{"compiled_default_expression":"NULL","default_evidence":["A comma-separated list of hostaddr values is also accepted, in which case each host in the list is tried in order. An empty item in the list causes the corresponding host name to be used, or the default host name if that is empty as well. See Section 32.1.1.3 for details."],"definition":"Numeric IP address of host to connect to. This should be in the standard IPv4 address format, e.g., 172.28.40.9 . If your machine supports IPv6, you can also use those addresses. TCP/IP communication is always used when a nonempty string is specified for this parameter. If this parameter is not specified, the value of host will be looked up to find the corresponding IP address — or, if host specifies an IP address, that value will be used directly. Using hostaddr allows the application to avoid a host name look-up, which might be important in applications with time constraints. However, a host name is required for GSSAPI or SSPI authentication methods, as well as for verify-full SSL certificate verification. The following rules are used: If host is specified without hostaddr , a host name lookup occurs. (When using PQconnectPoll , the lookup occurs when PQconnectPoll first considers this host name, and it may cause PQconnectPoll to block for a significant amount of time.) If hostaddr is specified without host , the value for hostaddr gives the server network address. The connection attempt will fail if the authentication method requires a host name. If both host and hostaddr are specified, the value for hostaddr gives the server network address. The value for host is ignored unless the authentication method requires it, in which case it will be used as the host name. Note that authentication is likely to fail if host is not the name of the server at network address hostaddr . Also, when both host and hostaddr are specified, host is used to identify the connection in a password file (see Section 32.16 ). A comma-separated list of hostaddr values is also accepted, in which case each host in the list is tried in order. An empty item in the list causes the corresponding host name to be used, or the default host name if that is empty as well. See Section 32.1.1.3 for details. Without either a host name or host address, libpq will connect using a local Unix-domain socket; or on Windows, it will attempt to connect to localhost .","documented":true,"environment":"PGHOSTADDR","keyword":"hostaddr"},"comparison_hash":"90f4bd94bbe9a4e92674b61c49e3f961826253701d15eaf8cdabb29bbfb88b88","default_evidence":["A comma-separated list of hostaddr values is also accepted, in which case each host in the list is tried in order. An empty item in the list causes the corresponding host name to be used, or the default host name if that is empty as well. See Section 32.1.1.3 for details."],"description":["Numeric IP address of host to connect to. This should be in the standard IPv4 address format, e.g., 172.28.40.9 . If your machine supports IPv6, you can also use those addresses. TCP/IP communication is always used when a nonempty string is specified for this parameter. If this parameter is not specified, the value of host will be looked up to find the corresponding IP address — or, if host specifies an IP address, that value will be used directly."],"documented":true,"environment":[{"description":"PGHOSTADDR behaves the same as the hostaddr connection parameter. This can be set instead of or in addition to PGHOST to avoid DNS lookup overhead.","name":"PGHOSTADDR","source_url":"/docs/18/libpq-envars.html"}],"facts":[{"label":"Client library","value":"libpq 18.6"},{"label":"Manual definition","value":"Documented"},{"label":"Source environment fallback","value":"PGHOSTADDR"},{"label":"Compiled fallback expression","value":"NULL"}],"keyword":"hostaddr","manual_html":"\u003cdiv\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt id=\"LIBPQ-CONNECT-HOSTADDR\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ehostaddr\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\n\u003cp\u003eNumeric IP address of host to connect to. This should be in the standard IPv4 address format, e.g., \u003ccode class=\"literal\"\u003e172.28.40.9\u003c/code\u003e. If your machine supports IPv6, you can also use those addresses. TCP/IP communication is always used when a nonempty string is specified for this parameter. If this parameter is not specified, the value of \u003ccode class=\"literal\"\u003ehost\u003c/code\u003e will be looked up to find the corresponding IP address — or, if \u003ccode class=\"literal\"\u003ehost\u003c/code\u003e specifies an IP address, that value will be used directly.\u003c/p\u003e\n\u003cp\u003eUsing \u003ccode class=\"literal\"\u003ehostaddr\u003c/code\u003e allows the application to avoid a host name look-up, which might be important in applications with time constraints. However, a host name is required for GSSAPI or SSPI authentication methods, as well as for \u003ccode class=\"literal\"\u003everify-full\u003c/code\u003e SSL certificate verification. The following rules are used:\u003c/p\u003e\n\u003cdiv class=\"itemizedlist\"\u003e\n\u003cul class=\"itemizedlist\"\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eIf \u003ccode class=\"literal\"\u003ehost\u003c/code\u003e is specified without \u003ccode class=\"literal\"\u003ehostaddr\u003c/code\u003e, a host name lookup occurs. (When using \u003ccode class=\"function\"\u003ePQconnectPoll\u003c/code\u003e, the lookup occurs when \u003ccode class=\"function\"\u003ePQconnectPoll\u003c/code\u003e first considers this host name, and it may cause \u003ccode class=\"function\"\u003ePQconnectPoll\u003c/code\u003e to block for a significant amount of time.)\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eIf \u003ccode class=\"literal\"\u003ehostaddr\u003c/code\u003e is specified without \u003ccode class=\"literal\"\u003ehost\u003c/code\u003e, the value for \u003ccode class=\"literal\"\u003ehostaddr\u003c/code\u003e gives the server network address. The connection attempt will fail if the authentication method requires a host name.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eIf both \u003ccode class=\"literal\"\u003ehost\u003c/code\u003e and \u003ccode class=\"literal\"\u003ehostaddr\u003c/code\u003e are specified, the value for \u003ccode class=\"literal\"\u003ehostaddr\u003c/code\u003e gives the server network address. The value for \u003ccode class=\"literal\"\u003ehost\u003c/code\u003e is ignored unless the authentication method requires it, in which case it will be used as the host name.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003cp\u003eNote that authentication is likely to fail if \u003ccode class=\"literal\"\u003ehost\u003c/code\u003e is not the name of the server at network address \u003ccode class=\"literal\"\u003ehostaddr\u003c/code\u003e. Also, when both \u003ccode class=\"literal\"\u003ehost\u003c/code\u003e and \u003ccode class=\"literal\"\u003ehostaddr\u003c/code\u003e are specified, \u003ccode class=\"literal\"\u003ehost\u003c/code\u003e is used to identify the connection in a password file (see \u003ca class=\"xref\" href=\"/docs/18/libpq-pgpass.html\" title=\"32.16. The Password File\"\u003eSection 32.16\u003c/a\u003e).\u003c/p\u003e\n\u003cp\u003eA comma-separated list of \u003ccode class=\"literal\"\u003ehostaddr\u003c/code\u003e values is also accepted, in which case each host in the list is tried in order. An empty item in the list causes the corresponding host name to be used, or the default host name if that is empty as well. See \u003ca class=\"xref\" href=\"/docs/18/libpq-connect.html#LIBPQ-MULTIPLE-HOSTS\" title=\"32.1.1.3. Specifying Multiple Hosts\"\u003eSection 32.1.1.3\u003c/a\u003e for details.\u003c/p\u003e\n\u003cp\u003eWithout either a host name or host address, \u003cspan class=\"application\"\u003elibpq\u003c/span\u003e will connect using a local Unix-domain socket; or on Windows, it will attempt to connect to \u003ccode class=\"literal\"\u003elocalhost\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","manual_path":"libpq-connect.html#LIBPQ-CONNECT-HOSTADDR","precedence_evidence":["The following environment variables can be used to select default connection parameter values, which will be used by PQconnectdb , PQsetdbLogin and PQsetdb if no value is directly specified by the calling code. These are useful to avoid hard-coding database connection information into simple client applications, for example.","Service names can be defined in either a per-user service file or a system-wide file. If the same service name exists in both the user and the system file, the user file takes precedence. By default, the per-user service file is named ~/.pg_service.conf . On Microsoft Windows, it is named %APPDATA%\\postgresql\\.pg_service.conf (where %APPDATA% refers to the Application Data subdirectory in the user's profile). A different file name can be specified by setting the environment variable PGSERVICEFILE . The system-wide file is named pg_service.conf . By default it is sought in the etc directory of the PostgreSQL installation (use pg_config --sysconfdir to identify this directory precisely). Another directory, but not a different file name, can be specified by setting the environment variable PGSYSCONFDIR .","Connection parameters obtained from a service file are combined with parameters obtained from other sources. A service file setting overrides the corresponding environment variable, and in turn can be overridden by a value given directly in the connection string. For example, using the above service file, a connection string service=mydb port=5434 will use host somehost , port 5434 , user admin , and other parameters as set by environment variables or built-in defaults."],"related":[{"label":"Connection service file","url":"/docs/18/libpq-pgservice.html"},{"label":"Password file","url":"/docs/18/libpq-pgpass.html"},{"label":"All libpq environment variables","url":"/docs/18/libpq-envars.html"}],"release":{"channel":"stable","evidence_kind":"English manual and source declarations","label":"18.6","major":"18","manifest":{"index":"index.html","major":"18","pages":1148,"pdf":{"A4":{"built_at":"2026-09-26","bytes":15865106,"pages":3154,"sha256":"19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190","url":"/files/documentation/pdf/18/postgresql-18-A4.pdf"},"US":{"built_at":"2026-09-26","bytes":15748059,"pages":3328,"sha256":"facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319","url":"/files/documentation/pdf/18/postgresql-18-US.pdf"}},"release":"18.6","source_mode":"en SGML built with pinned official archive","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","svg_assets":3,"tree":"18"},"ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sections":[{"paragraphs":["The following environment variables can be used to select default connection parameter values, which will be used by PQconnectdb , PQsetdbLogin and PQsetdb if no value is directly specified by the calling code. These are useful to avoid hard-coding database connection information into simple client applications, for example.","Service names can be defined in either a per-user service file or a system-wide file. If the same service name exists in both the user and the system file, the user file takes precedence. By default, the per-user service file is named ~/.pg_service.conf . On Microsoft Windows, it is named %APPDATA%\\postgresql\\.pg_service.conf (where %APPDATA% refers to the Application Data subdirectory in the user's profile). A different file name can be specified by setting the environment variable PGSERVICEFILE . The system-wide file is named pg_service.conf . By default it is sought in the etc directory of the PostgreSQL installation (use pg_config --sysconfdir to identify this directory precisely). Another directory, but not a different file name, can be specified by setting the environment variable PGSYSCONFDIR .","Connection parameters obtained from a service file are combined with parameters obtained from other sources. A service file setting overrides the corresponding environment variable, and in turn can be overridden by a value given directly in the connection string. For example, using the above service file, a connection string service=mydb port=5434 will use host somehost , port 5434 , user admin , and other parameters as set by environment variables or built-in defaults."],"title":"Default resolution and service-file precedence"},{"paragraphs":["PGHOSTADDR behaves the same as the hostaddr connection parameter. This can be set instead of or in addition to PGHOST to avoid DNS lookup overhead."],"title":"Environment variable evidence"}],"signature":"hostaddr","source_option":{"compiled_default_expression":"NULL","declaration":"\"hostaddr\", \"PGHOSTADDR\", NULL, NULL, \"Database-Host-IP-Address\", \"\", 45, offsetof(struct pg_conn, pghostaddr)","environment":"PGHOSTADDR","keyword":"hostaddr","source_notes":[]},"sources":[{"anchor":"LIBPQ-CONNECT-HOSTADDR","file":"libpq-connect.html","label":"18.6 English manual · libpq-connect.html","sha256":"c26a7fc3dcda6066cfe540641ae2690faf3d3c03277f30b4dfc2328ab45c212f","url":"/docs/18/libpq-connect.html#LIBPQ-CONNECT-HOSTADDR"},{"archive_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","file":"src/interfaces/libpq/fe-connect.c","label":"18.6 libpq connection option declarations","sha256":"44a6e386cbfd67ebe768d6ef5493098119c2e6b4796239d53e5ed7b122b206a5","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"},{"anchor":"","file":"libpq-envars.html","label":"18.6 English manual · libpq-envars.html","sha256":"d64db73f3d48127bb984a5f775e77b7bcca2ba4bd218333cf24a45fcdd7c4363","url":"/docs/18/libpq-envars.html"},{"anchor":"","file":"libpq-pgservice.html","label":"18.6 English manual · libpq-pgservice.html","sha256":"6035a3f0ee1d0fd80db5bf58834390b884eecd23206659bdf6f07560deea5aa7","url":"/docs/18/libpq-pgservice.html"}],"tables":[{"columns":[{"key":"name","label":"Variable"},{"key":"description","label":"Documented behavior"}],"key":"environment","rows":[{"description":"PGHOSTADDR behaves the same as the hostaddr connection parameter. This can be set instead of or in addition to PGHOST to avoid DNS lookup overhead.","name":{"text":"PGHOSTADDR","url":"/docs/18/libpq-envars.html"}}],"title":"Environment fallback"}]},"ManualEvidence":{"manual_path":"libpq-connect.html#LIBPQ-CONNECT-HOSTADDR","release":{"channel":"stable","evidence_kind":"English manual and source declarations","label":"18.6","major":"18","manifest":{"index":"index.html","major":"18","pages":1148,"pdf":{"A4":{"built_at":"2026-09-26","bytes":15865106,"pages":3154,"sha256":"19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190","url":"/files/documentation/pdf/18/postgresql-18-A4.pdf"},"US":{"built_at":"2026-09-26","bytes":15748059,"pages":3328,"sha256":"facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319","url":"/files/documentation/pdf/18/postgresql-18-US.pdf"}},"release":"18.6","source_mode":"en SGML built with pinned official archive","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","svg_assets":3,"tree":"18"},"ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sources":[{"anchor":"LIBPQ-CONNECT-HOSTADDR","file":"libpq-connect.html","label":"18.6 English manual · libpq-connect.html","sha256":"c26a7fc3dcda6066cfe540641ae2690faf3d3c03277f30b4dfc2328ab45c212f","url":"/docs/18/libpq-connect.html#LIBPQ-CONNECT-HOSTADDR"},{"archive_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","file":"src/interfaces/libpq/fe-connect.c","label":"18.6 libpq connection option declarations","sha256":"44a6e386cbfd67ebe768d6ef5493098119c2e6b4796239d53e5ed7b122b206a5","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"},{"anchor":"","file":"libpq-envars.html","label":"18.6 English manual · libpq-envars.html","sha256":"d64db73f3d48127bb984a5f775e77b7bcca2ba4bd218333cf24a45fcdd7c4363","url":"/docs/18/libpq-envars.html"},{"anchor":"","file":"libpq-pgservice.html","label":"18.6 English manual · libpq-pgservice.html","sha256":"6035a3f0ee1d0fd80db5bf58834390b884eecd23206659bdf6f07560deea5aa7","url":"/docs/18/libpq-pgservice.html"}]},"MeasuredEvidence":{}},"Text":{"Collection":"conn","Key":"hostaddr","SourceDatabase":"center","Version":"18","Locale":"en","Title":"hostaddr","Summary":"Numeric IP address of host to connect to. This should be in the standard IPv4 address format, e.g., 172.28.40.9 . If your machine supports IPv6, you can also use those addresses. TCP/IP communication is always used when a nonempty string is specified for this parameter. If this parameter is not specified, the value of host will be looked up to find the corresponding IP address — or, if host specifies an IP address, that value will be used directly.","BodyHTML":"\u003cdiv\u003e\u003cdl\u003e\u003cdt id=\"LIBPQ-CONNECT-HOSTADDR\"\u003e\u003cspan\u003e\u003ccode\u003ehostaddr\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\n\u003cp\u003eNumeric IP address of host to connect to. This should be in the standard IPv4 address format, e.g., \u003ccode\u003e172.28.40.9\u003c/code\u003e. If your machine supports IPv6, you can also use those addresses. TCP/IP communication is always used when a nonempty string is specified for this parameter. If this parameter is not specified, the value of \u003ccode\u003ehost\u003c/code\u003e will be looked up to find the corresponding IP address — or, if \u003ccode\u003ehost\u003c/code\u003e specifies an IP address, that value will be used directly.\u003c/p\u003e\n\u003cp\u003eUsing \u003ccode\u003ehostaddr\u003c/code\u003e allows the application to avoid a host name look-up, which might be important in applications with time constraints. However, a host name is required for GSSAPI or SSPI authentication methods, as well as for \u003ccode\u003everify-full\u003c/code\u003e SSL certificate verification. The following rules are used:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cul\u003e\n\u003cli\u003e\n\u003cp\u003eIf \u003ccode\u003ehost\u003c/code\u003e is specified without \u003ccode\u003ehostaddr\u003c/code\u003e, a host name lookup occurs. (When using \u003ccode\u003ePQconnectPoll\u003c/code\u003e, the lookup occurs when \u003ccode\u003ePQconnectPoll\u003c/code\u003e first considers this host name, and it may cause \u003ccode\u003ePQconnectPoll\u003c/code\u003e to block for a significant amount of time.)\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eIf \u003ccode\u003ehostaddr\u003c/code\u003e is specified without \u003ccode\u003ehost\u003c/code\u003e, the value for \u003ccode\u003ehostaddr\u003c/code\u003e gives the server network address. The connection attempt will fail if the authentication method requires a host name.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eIf both \u003ccode\u003ehost\u003c/code\u003e and \u003ccode\u003ehostaddr\u003c/code\u003e are specified, the value for \u003ccode\u003ehostaddr\u003c/code\u003e gives the server network address. The value for \u003ccode\u003ehost\u003c/code\u003e is ignored unless the authentication method requires it, in which case it will be used as the host name.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003cp\u003eNote that authentication is likely to fail if \u003ccode\u003ehost\u003c/code\u003e is not the name of the server at network address \u003ccode\u003ehostaddr\u003c/code\u003e. Also, when both \u003ccode\u003ehost\u003c/code\u003e and \u003ccode\u003ehostaddr\u003c/code\u003e are specified, \u003ccode\u003ehost\u003c/code\u003e is used to identify the connection in a password file (see \u003ca href=\"/docs/18/libpq-pgpass.html\" rel=\"nofollow\"\u003eSection 32.16\u003c/a\u003e).\u003c/p\u003e\n\u003cp\u003eA comma-separated list of \u003ccode\u003ehostaddr\u003c/code\u003e values is also accepted, in which case each host in the list is tried in order. An empty item in the list causes the corresponding host name to be used, or the default host name if that is empty as well. See \u003ca href=\"/docs/18/libpq-connect.html#LIBPQ-MULTIPLE-HOSTS\" rel=\"nofollow\"\u003eSection 32.1.1.3\u003c/a\u003e for details.\u003c/p\u003e\n\u003cp\u003eWithout either a host name or host address, \u003cspan\u003elibpq\u003c/span\u003e will connect using a local Unix-domain socket; or on Windows, it will attempt to connect to \u003ccode\u003elocalhost\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","SourceRevision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","ContentHash":"2d6302828474bf222d5ffa8ace8ee80366841d83627d6461ada50d73a61a4907","Payload":{"description":["Numeric IP address of host to connect to. This should be in the standard IPv4 address format, e.g., 172.28.40.9 . If your machine supports IPv6, you can also use those addresses. TCP/IP communication is always used when a nonempty string is specified for this parameter. If this parameter is not specified, the value of host will be looked up to find the corresponding IP address — or, if host specifies an IP address, that value will be used directly."],"manual_html":"\u003cdiv\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt id=\"LIBPQ-CONNECT-HOSTADDR\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ehostaddr\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\n\u003cp\u003eNumeric IP address of host to connect to. This should be in the standard IPv4 address format, e.g., \u003ccode class=\"literal\"\u003e172.28.40.9\u003c/code\u003e. If your machine supports IPv6, you can also use those addresses. TCP/IP communication is always used when a nonempty string is specified for this parameter. If this parameter is not specified, the value of \u003ccode class=\"literal\"\u003ehost\u003c/code\u003e will be looked up to find the corresponding IP address — or, if \u003ccode class=\"literal\"\u003ehost\u003c/code\u003e specifies an IP address, that value will be used directly.\u003c/p\u003e\n\u003cp\u003eUsing \u003ccode class=\"literal\"\u003ehostaddr\u003c/code\u003e allows the application to avoid a host name look-up, which might be important in applications with time constraints. However, a host name is required for GSSAPI or SSPI authentication methods, as well as for \u003ccode class=\"literal\"\u003everify-full\u003c/code\u003e SSL certificate verification. The following rules are used:\u003c/p\u003e\n\u003cdiv class=\"itemizedlist\"\u003e\n\u003cul class=\"itemizedlist\"\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eIf \u003ccode class=\"literal\"\u003ehost\u003c/code\u003e is specified without \u003ccode class=\"literal\"\u003ehostaddr\u003c/code\u003e, a host name lookup occurs. (When using \u003ccode class=\"function\"\u003ePQconnectPoll\u003c/code\u003e, the lookup occurs when \u003ccode class=\"function\"\u003ePQconnectPoll\u003c/code\u003e first considers this host name, and it may cause \u003ccode class=\"function\"\u003ePQconnectPoll\u003c/code\u003e to block for a significant amount of time.)\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eIf \u003ccode class=\"literal\"\u003ehostaddr\u003c/code\u003e is specified without \u003ccode class=\"literal\"\u003ehost\u003c/code\u003e, the value for \u003ccode class=\"literal\"\u003ehostaddr\u003c/code\u003e gives the server network address. The connection attempt will fail if the authentication method requires a host name.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eIf both \u003ccode class=\"literal\"\u003ehost\u003c/code\u003e and \u003ccode class=\"literal\"\u003ehostaddr\u003c/code\u003e are specified, the value for \u003ccode class=\"literal\"\u003ehostaddr\u003c/code\u003e gives the server network address. The value for \u003ccode class=\"literal\"\u003ehost\u003c/code\u003e is ignored unless the authentication method requires it, in which case it will be used as the host name.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003cp\u003eNote that authentication is likely to fail if \u003ccode class=\"literal\"\u003ehost\u003c/code\u003e is not the name of the server at network address \u003ccode class=\"literal\"\u003ehostaddr\u003c/code\u003e. Also, when both \u003ccode class=\"literal\"\u003ehost\u003c/code\u003e and \u003ccode class=\"literal\"\u003ehostaddr\u003c/code\u003e are specified, \u003ccode class=\"literal\"\u003ehost\u003c/code\u003e is used to identify the connection in a password file (see \u003ca class=\"xref\" href=\"/docs/18/libpq-pgpass.html\" title=\"32.16. The Password File\"\u003eSection 32.16\u003c/a\u003e).\u003c/p\u003e\n\u003cp\u003eA comma-separated list of \u003ccode class=\"literal\"\u003ehostaddr\u003c/code\u003e values is also accepted, in which case each host in the list is tried in order. An empty item in the list causes the corresponding host name to be used, or the default host name if that is empty as well. See \u003ca class=\"xref\" href=\"/docs/18/libpq-connect.html#LIBPQ-MULTIPLE-HOSTS\" title=\"32.1.1.3. Specifying Multiple Hosts\"\u003eSection 32.1.1.3\u003c/a\u003e for details.\u003c/p\u003e\n\u003cp\u003eWithout either a host name or host address, \u003cspan class=\"application\"\u003elibpq\u003c/span\u003e will connect using a local Unix-domain socket; or on Windows, it will attempt to connect to \u003ccode class=\"literal\"\u003elocalhost\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","related":[{"label":"Connection service file","url":"/docs/18/libpq-pgservice.html"},{"label":"Password file","url":"/docs/18/libpq-pgpass.html"},{"label":"All libpq environment variables","url":"/docs/18/libpq-envars.html"}],"sections":[{"paragraphs":["The following environment variables can be used to select default connection parameter values, which will be used by PQconnectdb , PQsetdbLogin and PQsetdb if no value is directly specified by the calling code. These are useful to avoid hard-coding database connection information into simple client applications, for example.","Service names can be defined in either a per-user service file or a system-wide file. If the same service name exists in both the user and the system file, the user file takes precedence. By default, the per-user service file is named ~/.pg_service.conf . On Microsoft Windows, it is named %APPDATA%\\postgresql\\.pg_service.conf (where %APPDATA% refers to the Application Data subdirectory in the user's profile). A different file name can be specified by setting the environment variable PGSERVICEFILE . The system-wide file is named pg_service.conf . By default it is sought in the etc directory of the PostgreSQL installation (use pg_config --sysconfdir to identify this directory precisely). Another directory, but not a different file name, can be specified by setting the environment variable PGSYSCONFDIR .","Connection parameters obtained from a service file are combined with parameters obtained from other sources. A service file setting overrides the corresponding environment variable, and in turn can be overridden by a value given directly in the connection string. For example, using the above service file, a connection string service=mydb port=5434 will use host somehost , port 5434 , user admin , and other parameters as set by environment variables or built-in defaults."],"title":"Default resolution and service-file precedence"},{"paragraphs":["PGHOSTADDR behaves the same as the hostaddr connection parameter. This can be set instead of or in addition to PGHOST to avoid DNS lookup overhead."],"title":"Environment variable evidence"}],"tables":[{"columns":[{"key":"name","label":"Variable"},{"key":"description","label":"Documented behavior"}],"key":"environment","rows":[{"description":"PGHOSTADDR behaves the same as the hostaddr connection parameter. This can be set instead of or in addition to PGHOST to avoid DNS lookup overhead.","name":{"text":"PGHOSTADDR","url":"/docs/18/libpq-envars.html"}}],"title":"Environment fallback"}]}},"RequestedLocale":"zh-Hans","Fallback":true,"Versions":["10","11","12","13","14","15","16","17","18","19","20"],"Locales":["en"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
