Skip to content
statance
MenuClose
← All ports

Port 11211: Memcached

Critical risk

Port 11211 is Memcached, an in-memory key-value cache used to speed up web applications. It should not be reachable from the public internet.

Port
11211
Protocol
TCP and UDP
Service
Memcached
Expose to internet?
No

Is port 11211 safe to open?

Memcached has no authentication in its default text protocol, so anyone can read and overwrite cached data such as sessions. Over UDP it can return responses tens of thousands of times larger than the request, which made it the source of record-breaking amplification DDoS attacks in 2018. Memcached 1.5.6 and later disable UDP by default.

How to secure Memcached

  • Listen on localhost only: -l 127.0.0.1 (in /etc/memcached.conf or the service options).
  • Disable UDP with -U 0 on older versions.
  • Enable SASL authentication if remote clients must connect.
  • Block TCP and UDP 11211 at the firewall.

Check if port 11211 is open

Linux: what is listening on this port

sudo ss -tulpn | grep ':11211 '

Windows (PowerShell): what is listening

Get-NetTCPConnection -LocalPort 11211 -State Listen | Select-Object LocalAddress, OwningProcess, @{n='Process';e={(Get-Process -Id $_.OwningProcess).Name}}

From another machine: is it reachable

nc -zv HOST 11211 # or nmap -p 11211 HOST # Windows Test-NetConnection HOST -Port 11211

Test the Memcached service itself

echo stats | nc -q1 HOST 11211

Restrict port 11211 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:11211:11211) 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 11211 proto tcp sudo ufw deny 11211/tcp

firewalld: allow one source network only

sudo firewall-cmd --permanent --remove-port=11211/tcp sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="10.0.0.0/8" port port="11211" protocol="tcp" accept' sudo firewall-cmd --reload

iptables

sudo iptables -A INPUT -p tcp --dport 11211 -s 10.0.0.0/8 -j ACCEPT sudo iptables -A INPUT -p tcp --dport 11211 -j DROP

Windows Firewall (PowerShell, as Administrator)

New-NetFirewallRule -DisplayName "Block 11211 from internet" -Direction Inbound -Protocol TCP -LocalPort 11211 -RemoteAddress Internet -Action Block

Monitor port 11211

Run a TCP port monitor against your public IP on port 11211: 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

Port 6379RedisCritical risk
Port 3306MySQL / MariaDBHigh risk
Port 123NTPMedium risk

FAQ

What is port 11211 used for?

Port 11211 is Memcached, an in-memory key-value cache used to speed up web applications.

Is it safe to open port 11211?

Not to the public internet. Memcached has no authentication in its default text protocol, so anyone can read and overwrite cached data such as sessions. Over UDP it can return responses tens of thousands of times larger than the request, which made it the source of record-breaking amplification DDoS attacks in 2018. Memcached 1.5.6 and later disable UDP by default.

Is port 11211 TCP or UDP?

Memcached uses TCP and UDP on port 11211.

How do I check if port 11211 is open?

On the server, run sudo ss -tulpn | grep ':11211 ' (Linux) or Get-NetTCPConnection -LocalPort 11211 (Windows) to see what is listening. From another machine, run nc -zv HOST 11211 or Test-NetConnection HOST -Port 11211.

All ports →

Know the moment a port stops answering.

TCP, HTTP, DNS and SSL checks from six regions, plus server metrics from a one-line agent.