<?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: Varid Vaya Yusuf</title>
    <description>The latest articles on DEV Community by Varid Vaya Yusuf (@varvay).</description>
    <link>https://dev.to/varvay</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F818050%2Fc6beb513-ad23-457d-b3dd-e3db81280797.jpeg</url>
      <title>DEV Community: Varid Vaya Yusuf</title>
      <link>https://dev.to/varvay</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/varvay"/>
    <language>en</language>
    <item>
      <title>Slow mDNS Name Resolution</title>
      <dc:creator>Varid Vaya Yusuf</dc:creator>
      <pubDate>Tue, 24 Jun 2025 23:14:47 +0000</pubDate>
      <link>https://dev.to/varvay/mdns-name-resolution-slow-41d</link>
      <guid>https://dev.to/varvay/mdns-name-resolution-slow-41d</guid>
      <description>&lt;p&gt;Today is my first time working with mDNS, and I set everything up correctly, so now it's test time. I'm on macOS, but I think this issue might apply to other operating systems too. I'm writing this because a lot of people online don't seem to fully understand the problem. Many don’t even realize they’re using mDNS and just expect the .local domain to work magically.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Issue
&lt;/h2&gt;

&lt;p&gt;Everything works fine, even when I use curl with the mDNS name, but the response time is always consistently 5 seconds.&lt;/p&gt;

&lt;p&gt;Here’s what I tested before finding the solution:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;I used &lt;code&gt;dns-sd -B _http._tcp&lt;/code&gt; to discover services, and got results in milliseconds.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I did an IP address lookup with &lt;code&gt;dns-sd -G v4 &amp;lt;hostname&amp;gt;.local&lt;/code&gt;, and the result was also in milliseconds.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;But when I curl an API, it takes 5 seconds to get a response.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;It turns out that curl (or whatever tool you’re using) is likely waiting for an IPv6 address when resolving the domain name. You can see this in the packet capture from Wireshark:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh2roji8rsug9gv87y27k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh2roji8rsug9gv87y27k.png" alt="Wireshark Dump Result" width="800" height="202"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The problem is that the host only supports IPv4, so curl waits for the IPv6 resolution for about 5 seconds before it falls back to IPv4 and gets a response right away.&lt;/p&gt;

&lt;p&gt;There are a few ways to fix this, depending on your setup and needs. You can force curl (or your tool) to use IPv4 by using &lt;code&gt;curl -4&lt;/code&gt;, or you can configure the host to support IPv6.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Found Online
&lt;/h2&gt;

&lt;p&gt;I couldn’t find any clear explanations online. Most people don’t realize they’re relying on mDNS with the .local hostname. Others try to bypass the issue without understanding the cause, like adding the hostname to /etc/hosts, which defeats the purpose of using mDNS in the first place.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
