Port 389 is LDAP, the directory protocol behind Active Directory and OpenLDAP. Applications query it for users, groups and authentication. It should not be reachable from the public internet.
- Port
- 389
- Protocol
- TCP and UDP
- Service
- LDAP
- Expose to internet?
- No
- Also used by
- Active Directory, OpenLDAP, 389 Directory Server, FreeIPA
Is port 389 safe to open?
A directory server holds your user accounts, so exposing it invites password attacks and information gathering. Anonymous binds can reveal usernames and group membership. Active Directory also answers connectionless LDAP (CLDAP) on UDP 389, which is abused for amplification DDoS when exposed.
How to secure LDAP
- Never expose 389 to the internet; reach the directory over a VPN or private network.
- Disable anonymous binds (OpenLDAP:
disallow bind_anon). - Require LDAP signing and channel binding on Active Directory domain controllers.
- Use LDAPS on 636 or StartTLS so credentials are encrypted.
Check if port 389 is open
Linux: what is listening on this port
sudo ss -tulpn | grep ':389 'Windows (PowerShell): what is listening
Get-NetTCPConnection -LocalPort 389 -State Listen | Select-Object LocalAddress, OwningProcess, @{n='Process';e={(Get-Process -Id $_.OwningProcess).Name}}From another machine: is it reachable
nc -zv HOST 389
# or
nmap -p 389 HOST
# Windows
Test-NetConnection HOST -Port 389Test the LDAP service itself
ldapsearch -x -H ldap://HOST -s base -b "" namingContextsRestrict port 389 in the firewall
Replace 10.0.0.0/8 with the network or address that needs access. Docker publishes container ports through its own iptables rules, which bypass ufw; bind published ports to 127.0.0.1 (-p 127.0.0.1:389:389) instead of relying on the host firewall.
ufw: allow only your private network, deny everyone else
sudo ufw allow from 10.0.0.0/8 to any port 389 proto tcp
sudo ufw deny 389/tcpfirewalld: allow one source network only
sudo firewall-cmd --permanent --remove-port=389/tcp
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="10.0.0.0/8" port port="389" protocol="tcp" accept'
sudo firewall-cmd --reloadiptables
sudo iptables -A INPUT -p tcp --dport 389 -s 10.0.0.0/8 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 389 -j DROPWindows Firewall (PowerShell, as Administrator)
New-NetFirewallRule -DisplayName "Block 389 from internet" -Direction Inbound -Protocol TCP -LocalPort 389 -RemoteAddress Internet -Action BlockMonitor port 389
Run a TCP port monitor against your public IP on port 389: here, a failed connection is the healthy result, so you know the firewall is still doing its job. On Linux, the Statance agent also reports every listening port on the server. TCP port monitoring.
Related ports
FAQ
What is port 389 used for?
Port 389 is LDAP, the directory protocol behind Active Directory and OpenLDAP. Applications query it for users, groups and authentication. It is also used by Active Directory, OpenLDAP, 389 Directory Server, FreeIPA.
Is it safe to open port 389?
Not to the public internet. A directory server holds your user accounts, so exposing it invites password attacks and information gathering. Anonymous binds can reveal usernames and group membership. Active Directory also answers connectionless LDAP (CLDAP) on UDP 389, which is abused for amplification DDoS when exposed.
Is port 389 TCP or UDP?
LDAP uses TCP and UDP on port 389.
How do I check if port 389 is open?
On the server, run sudo ss -tulpn | grep ':389 ' (Linux) or Get-NetTCPConnection -LocalPort 389 (Windows) to see what is listening. From another machine, run nc -zv HOST 389 or Test-NetConnection HOST -Port 389.
Know the moment a port stops answering.
TCP, HTTP, DNS and SSL checks from six regions, plus server metrics from a one-line agent.