• 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
You are here: Home / How-to / How to Test Memcached Connectivity

How to Test Memcached Connectivity

November 30, 20161 Comment

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

Leave a Reply Cancel reply

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

Primary Sidebar

Recent Posts

  • How To Get SMETS1/2 Smart Meter Data into HomeAssistant the Easy Way
  • How to Install 7zip on Ubuntu 18.04 LTS (Bionic Beaver)
  • How to Install the NewRelic MySQL Plugin
  • Repair “Repository Error: database disk image is malformed” YUM Issue
  • How to Check NTP Connectivity and Function on the Command Line

Recent Comments

  • himanshu on How to Test Memcached Connectivity
  • moun on How to Perform a GET Request with CURL via the Command Line
  • Karl on How to Install rar/unrar on Ubuntu 18.04 LTS (Bionic Beaver)
  • John on How to Install rar/unrar on Ubuntu 18.04 LTS (Bionic Beaver)
  • How to Install rar/unrar on Ubuntu 16.04 LTS (Xenial) - KJBweb on How to Install rar/unrar on Ubuntu 18.04 LTS (Bionic Beaver)

Archives

  • November 2022
  • February 2019
  • August 2018
  • November 2016

Categories

  • Examples
  • Hardware
  • How-to
  • Quick Fixes

Copyright © 2023 · WordPress · Log in