• Skip to main content
  • Skip to secondary menu
  • Skip to primary sidebar

KJBweb

Technical Notes & How To's

  • Home
  • How-to
  • Quick Fixes
  • Examples
  • Hardware
  • Privacy
You are here: Home / How-to / How to Test Memcached Connectivity

How to Test Memcached Connectivity

November 30, 20162 Comments

If you’re looking to verify connectivity from your application server to your Memcached server, a simple CURL request won’t do (much to my dismay).

Instead, you’ll need to use either Telnet or Netcat (nc) to poll the Memcached server for it’s stats, this can be done like so:

Memcached Telnet Connectivity Test

First, open a telnet session to your Memcached server on the appropriate port; by default Memcached listens on port 11211:

telnet memcached.yourdomain.com 11211

All being well, you should then be greeted with the following output:

Trying 208.67.222.124...
Connected to memcached.yourdomain.com.
Escape character is '^]'.

Typing “stats” should yield the following result:

stats
STAT pid 20781
STAT uptime 169659
STAT time 1480504602
STAT version 1.4.4
STAT pointer_size 64
STAT rusage_user 2.405634
STAT rusage_system 1.338796
STAT curr_connections 5
etc...

Memcached Netcat Connectivity Test

Netcat is a little nicer, in that you can connect and pull stats from your Memcached server using just the one command, run the following from your application server:

echo stats | nc memcached.yourdomain.com 11211

This should yield the following output and close automatically:

Trying 172.17.96.213...
Connected to memcached.yourdomain.com.
Escape character is '^]'.
stats
STAT pid 20781
STAT uptime 169659
STAT time 1480504602
STAT version 1.4.4
STAT pointer_size 64
STAT rusage_user 2.405634
STAT rusage_system 1.338796
STAT curr_connections 5
...
...
...
STAT total_items 536
STAT evictions 0
END
quit
Connection closed by foreign host.

There you have it, here’s how to test connectivity to your Memcached server using both Netcat and Telnet, if you have any queries be sure to use the comments section below.

Filed Under: How-to Tagged With: memcache

Reader Interactions

Comments

  1. himanshu says

    December 4, 2020 at 5:05 pm

    echo stats | nc memcached.yourdomain.com 11211
    By using this it can start memcached but not closing automatically

    Reply
    • martin says

      February 1, 2024 at 12:40 am

      Noticed the same thing, does not close automatically.

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Copyright © 2025 · WordPress · Log in