---
name: "gai_strerror"
section: "3"
platform: "macos"
package: "Libinfo"
version: "600"
release: "macOS 26.5"
platforms: ["linux", "freebsd", "macos"]
url: "https://new.carta.tech/gai_strerror"
---

# gai\_strerror(3)

get error message string from EAI\_xxx error code

## NAME

**gai\_strerror** – get error message string from EAI\_xxx error code

## SYNOPSIS

**#include \<sys/types.h\>**

**#include \<sys/socket.h\>**

**#include \<netdb.h\>**

*const char \**\

**gai\_strerror**(*int ecode*);

## DESCRIPTION

The **gai\_strerror**() function returns an error message string corresponding to the error code returned by [getaddrinfo(3)](/getaddrinfo/3.md) or [getnameinfo(3)](/getnameinfo/3.md).

The following error codes and their meaning are defined in ⟨netdb.h⟩:

- EAI\_ADDRFAMILY

  address family for nodename not supported

- EAI\_AGAIN

  temporary failure in name resolution

- EAI\_BADFLAGS

  invalid value for *ai\_flags*

- EAI\_BADHINTS

  invalid value for *hints*

- EAI\_FAIL

  non-recoverable failure in name resolution

- EAI\_FAMILY

  *ai\_family* not supported

- EAI\_MEMORY

  memory allocation failure

- EAI\_NODATA

  no address associated with nodename

- EAI\_NONAME

  *hostname* or *servname* not provided, or not known

- EAI\_OVERFLOW

  argument buffer overflow

- EAI\_PROTOCOL

  resolved protocol is unknown

- EAI\_SERVICE

  *servname* not supported for *ai\_socktype*

- EAI\_SOCKTYPE

  *ai\_socktype* not supported

- EAI\_SYSTEM

  system error returned in *errno*

## RETURN VALUES

The **gai\_strerror**() function returns a pointer to the error message string corresponding to *ecode*. If *ecode* is out of range, an implementation-specific error message string is returned.

## SEE ALSO

[getaddrinfo(3)](/getaddrinfo/3.md), [getnameinfo(3)](/getnameinfo/3.md)
