Port 389 (LDAP)

Port 389 is the port of LDAP (Lightweight Directory Access Protocol), the protocol systems and applications use to access a central directory service of…

Key facts

Port
389
Protocols
TCP, UDP
Range
System port (Well-Known), 0-1023
IANA service name
ldap

IANA assigns ports in this range to well-known services, under RFC 6335.

About port 389

Port 389 is the port of LDAP (Lightweight Directory Access Protocol), the protocol systems and applications use to access a central directory service of users, groups, and permissions, over TCP. A connection on port 389 starts unencrypted and switches to an encrypted connection with the StartTLS operation.

The protocol is defined in RFC 4511, and IANA registers port 389 for the ldap service, over TCP and UDP.

What port 389 is used for

  • Central user management: servers, computers, and applications check usernames and passwords against one directory server, instead of managing users on each system separately.
  • Active Directory: Windows domain controllers answer LDAP queries on port 389.
  • Application login: mail systems, internal portals, and VPN servers authenticate users against the directory.
  • Address book: email clients look up contacts in the organization's directory.

For a connection that's encrypted from the start, use port 636.

Port 389 in the firewall

A directory server usually serves only the internal network, so port 389 shouldn't be open to the internet. Allow access only from the servers and networks that need it:

  • UFW: ufw allow from 10.0.0.0/24 to any port 389 proto tcp
  • firewalld: firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="10.0.0.0/24" port port="389" protocol="tcp" accept'

When an application on a remote server needs access to the directory, it's better to connect it over a VPN than to open the port to public addresses.

Risks and security

With a plain login on port 389, without StartTLS, the password crosses the network as clear text. In addition, Active Directory domain controllers also answer queries over UDP on port 389, and a server exposed to the internet over UDP can be abused for amplification attacks.

  • Require an encrypted connection: StartTLS on port 389, or a connection on port 636.
  • Disable anonymous login when you don't need it.
  • Create service accounts for applications with read-only permissions, only for the part of the directory they need.
  • Block port 389, over TCP and UDP, for every address outside the internal network.

Commands to check and configure

  • ss -tulnp | grep ':389 '

    Checks whether the directory server is listening on port 389, over TCP and UDP.

  • nc -zv ldap.example.com 389

    Checks from your computer whether port 389 on the directory server is reachable.

  • openssl s_client -connect ldap.example.com:389 -starttls ldap

    Checks that the server supports StartTLS on port 389, and shows its certificate details.

  • ldapsearch -x -H ldap://ldap.example.com -ZZ -D "cn=reader,dc=example,dc=com" -W -b "dc=example,dc=com" "(uid=jdoe)"

    Searches the directory for a user over a connection that must switch to StartTLS (the -ZZ option). The password is prompted for separately.

  • ufw allow from 10.0.0.0/24 to any port 389 proto tcp

    Allows access to port 389 only from the given internal network (UFW).

  • firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="10.0.0.0/24" port port="389" protocol="tcp" accept'

    Allows access to port 389 only from the given internal network in firewalld. Then run firewall-cmd --reload.

Port 389 in the IANA registry

Port Protocol Service IANA registry description
389 TCP ldap Lightweight Directory Access Protocol
389 UDP ldap Lightweight Directory Access Protocol

Data source: IANA Service Name and Transport Protocol Port Number Registry (opens in a new tab)

Port 389 FAQ

What's the difference between port 389 and port 636?

Both ports are used for LDAP. On port 389, the connection starts unencrypted and switches to an encrypted connection with StartTLS, while on port 636 the connection is encrypted from the very first moment. Either way, the password travels encrypted, as long as the application is set to use encryption.

Does Active Directory use LDAP?

Yes. Active Directory domain controllers answer LDAP queries on port 389 and port 636. In addition, the Active Directory Global Catalog, which lets you search across all of the organization's domains, uses ports 3268 and 3269.

What is a Bind in LDAP?

It's the authentication operation against the directory server. Authentication uses the full name of the entry in the directory (DN) and a password, and when the server allows it, you can also connect anonymously. Applications perform a Bind with a service account to search the directory, and then a Bind with the user's details to check their password.

How do I connect securely to a remote LDAP server?

Set the application to use an encrypted connection, StartTLS or LDAPS, and allow access in the firewall only from known addresses. For occasional work from your own computer, an SSH tunnel lets you connect to the directory without opening port 389 to the internet.

Shopping cart

Your cart is emptyYou can start with one of our popular plans.

Site search

Accessibility

Text size
100%
Accessibility statement