<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: 0xpremf</title>
    <description>The latest articles on DEV Community by 0xpremf (@0xpremf).</description>
    <link>https://dev.to/0xpremf</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4009871%2F7fb05531-6cc3-4299-bda9-348aacb18db5.jpg</url>
      <title>DEV Community: 0xpremf</title>
      <link>https://dev.to/0xpremf</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/0xpremf"/>
    <language>en</language>
    <item>
      <title>Debugging a Redis Connection That Wasn't Actually Broken</title>
      <dc:creator>0xpremf</dc:creator>
      <pubDate>Tue, 30 Jun 2026 16:08:08 +0000</pubDate>
      <link>https://dev.to/0xpremf/debugging-a-redis-connection-that-wasnt-actually-broken-3pjk</link>
      <guid>https://dev.to/0xpremf/debugging-a-redis-connection-that-wasnt-actually-broken-3pjk</guid>
      <description>&lt;p&gt;So I was building a little Visit Counter app with Spring Boot and Redis nothing fancy, just bump a number every time someone hits a page. Should've been an easy weekend project. Instead I spent a solid hour convinced Redis had personally betrayed me.&lt;/p&gt;

&lt;h2&gt;
  
  
  Okay so here's what happened
&lt;/h2&gt;

&lt;p&gt;Everything looked fine on the surface. The app ran, no errors, no red text screaming at me in the console. But when I went to actually check what was in Redis, things got weird.&lt;/p&gt;

&lt;p&gt;I popped open &lt;code&gt;redis-cli&lt;/code&gt; to peek at the data, expecting to see something clean like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;home
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What I actually got was this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"\xac\xed\x00\x05t\x00\x04home"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Yeah. That.&lt;/p&gt;

&lt;p&gt;My brain immediately went to the worst-case scenario: "great, Redis is broken, the connection's busted, something's corrupted, I'm going to be here all night." Classic developer panic spiral.&lt;/p&gt;

&lt;h2&gt;
  
  
  Chasing my own tail
&lt;/h2&gt;

&lt;p&gt;So I checked the connection. Is Redis even running? Yep. Right host, right port? Yep. Can the app actually talk to it? Also yep. Everything I poked at said "this is fine," but the data in Redis very much did not look fine.&lt;/p&gt;

&lt;p&gt;This is the annoying part of debugging: the symptom (ugly garbage text in &lt;code&gt;redis-cli&lt;/code&gt;) &lt;em&gt;really&lt;/em&gt; looks like a broken connection. It's got that "something is corrupted" energy. So naturally I kept circling back to "but is it really connected though?" even after I'd already confirmed it ten times.&lt;/p&gt;

&lt;p&gt;Turns out I was debugging the wrong layer entirely.&lt;/p&gt;

&lt;h2&gt;
  
  
  The actual culprit
&lt;/h2&gt;

&lt;p&gt;Buried in my config, I had this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Configuration&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;RedisConfig&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nd"&gt;@Bean&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;RedisTemplate&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Object&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;redisTemplate&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;RedisConnectionFactory&lt;/span&gt; &lt;span class="n"&gt;connectionFactory&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;RedisTemplate&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Object&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;template&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;RedisTemplate&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;gt;();&lt;/span&gt;
        &lt;span class="n"&gt;template&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setConnectionFactory&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;connectionFactory&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="c1"&gt;// no serializers set — oops&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;template&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I'd made my own &lt;code&gt;RedisTemplate&lt;/code&gt; bean at some point, probably copy-pasted from a tutorial or an old project, and completely forgot Spring Boot already auto-configures one for you. My custom bean took priority, which would've been totally fine... except I never told it how to serialize anything.&lt;/p&gt;

&lt;p&gt;Without a serializer set, it just defaults to Java's built-in &lt;code&gt;JdkSerializationRedisSerializer&lt;/code&gt;. Which doesn't store plain strings — it stores actual Java object serialization, binary blobs with class metadata baked in. That weird &lt;code&gt;\xac\xed&lt;/code&gt; at the start of my "broken" data? That's literally Java's magic number for "hey, this is a serialized object." Redis wasn't corrupted at all. It was doing exactly what I told it to do I just never told it to store strings like a normal person.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fixing it
&lt;/h2&gt;

&lt;p&gt;Two options here, and honestly either works:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. just delete the custom bean.&lt;/strong&gt; Spring Boot's default already handles strings fine. Less code, fewer ways to mess it up.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. keep your custom bean, but actually configure it properly:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Configuration&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;RedisConfig&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nd"&gt;@Autowired&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;RedisConnectionFactory&lt;/span&gt; &lt;span class="n"&gt;redisConnectionFactory&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="nd"&gt;@Primary&lt;/span&gt;
    &lt;span class="nd"&gt;@Bean&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;RedisTemplate&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;redisTemplate&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;RedisTemplate&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;redisTemplate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;RedisTemplate&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;gt;();&lt;/span&gt;
        &lt;span class="n"&gt;redisTemplate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setConnectionFactory&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;redisConnectionFactory&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;redisTemplate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setKeySerializer&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;RedisSerializer&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;string&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
        &lt;span class="n"&gt;redisTemplate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setValueSerializer&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;RedisSerializer&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;string&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
        &lt;span class="n"&gt;redisTemplate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setHashKeySerializer&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;RedisSerializer&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;string&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
        &lt;span class="n"&gt;redisTemplate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setHashValueSerializer&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;RedisSerializer&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;string&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;redisTemplate&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I went with deleting the custom bean in the end, just to keep things simple. But if you do need a custom one (say, custom connection settings or interceptors), at least set those serializers explicitly so future-you doesn't have this exact same 2 a.m. panic.&lt;/p&gt;

&lt;p&gt;Once that was sorted, &lt;code&gt;redis-cli&lt;/code&gt; finally showed me what I'd wanted to see the whole time:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;127.0.0.1:6379&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;KEYS &lt;span class="k"&gt;*&lt;/span&gt;
&lt;span class="go"&gt;1) "home"
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Beautiful. Readable. No more cursed escape sequences.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I actually took away from this
&lt;/h2&gt;

&lt;p&gt;Don't assume the dependency is broken just because the output looks broken. Garbage-looking data is way more likely to be a "you told it to do this" problem than a "this tool is fundamentally broken" problem. Tools are usually doing exactly what you configured them to do, even when that configuration was accidental.&lt;/p&gt;

&lt;p&gt;THE MOST IMPORTANT Spring Boot's auto-configuration is genuinely good. I didn't need a custom &lt;code&gt;RedisTemplate&lt;/code&gt; at all. I made one because I'd seen it in some old tutorial and just assumed it was necessary. Lesson learned: don't override the defaults unless you actually have a reason to.&lt;/p&gt;

&lt;p&gt;And serializers are sneaky. They quietly decide what your data looks like once it's stored, completely separate from whether the connection itself is healthy. You can have a perfectly working Redis instance and still end up with data that looks like it came from a different planet, just because of one missing line of config.&lt;/p&gt;

&lt;p&gt;If I'd just followed a more boring, structured process from the start, I would've saved myself the hour:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Is the code actually running the path I think it is?&lt;/li&gt;
&lt;li&gt;Is the external service (Redis) actually up?&lt;/li&gt;
&lt;li&gt;Is the framework configuration doing what I expect (beans, serializers, all that)?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I jumped straight to "Redis must be broken" because that felt like the scariest, most dramatic explanation. In reality, the boring answer, check your own config first — is almost always right. Lesson filed away for next time, even if I probably won't fully learn it until I do this again in six months.&lt;/p&gt;

</description>
      <category>database</category>
      <category>debugging</category>
      <category>java</category>
      <category>springboot</category>
    </item>
  </channel>
</rss>
