# DNS Server | Rust | dns: buffer size too small

**URL:** <https://forum.codecrafters.io/t/dns-server-rust-dns-buffer-size-too-small/6370>\
**Category:** Challenges\
**Tags:** challenge:dns-server\
**Created:** [March 9, 2025, 4:57pm UTC](https://forum.codecrafters.io/t/dns-server-rust-dns-buffer-size-too-small/6370 "2025-03-09T16:57:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![roman-barman](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/roman-barman/32/6526_2.png) [@roman-barman](https://forum.codecrafters.io/u/roman-barman)\
**Post date:** [March 9, 2025, 4:57pm UTC](https://forum.codecrafters.io/t/dns-server-rust-dns-buffer-size-too-small/6370/1 "2025-03-09T16:57:56Z")

</div>

In the “Write question section” task tests have logs:

```auto
remote: [tester::#BF2] Running tests for Stage #BF2 (Write question section)
remote: [tester::#BF2] Starting DNS server on 127.0.0.1:2053
remote: [tester::#BF2] Running program
remote: [tester::#BF2] DNS resolver listening on 127.0.0.1:5354
remote: [tester::#BF2] Connecting to 127.0.0.1:2053 using UDP
remote: [your_program] Logs from your program will appear here!
remote: [tester::#BF2] Querying `A` record for codecrafters.io.
remote: [tester::#BF2] Sending Request: (Messages with >>> prefix are part of this log)
remote: [tester::#BF2] >>> ;; opcode: QUERY, status: NOERROR, id: 1234
remote: [your_program] Received 33 bytes from 127.0.0.1:60055
remote: [your_program] Send 33 bytes from 127.0.0.1:60055
remote: [tester::#BF2] >>> ;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
remote: [tester::#BF2] >>> 
remote: [tester::#BF2] >>> ;; QUESTION SECTION:
remote: [tester::#BF2] >>> ;codecrafters.io. IN A
remote: [tester::#BF2] >>> 
remote: [your_program] Success send response to 127.0.0.1:60055
remote: [your_program] Received 33 bytes from 127.0.0.1:49118
remote: [your_program] Send 33 bytes from 127.0.0.1:49118
remote: [your_program] Success send response to 127.0.0.1:49118
remote: [tester::#BF2] dns: buffer size too small
remote: [tester::#BF2] Test failed
remote: [tester::#BF2] Terminating program
remote: [tester::#BF2] Shutting down DNS resolver server...
remote: [tester::#BF2] Program terminated successfully

```

Could somebody help with this issue `dns: buffer size too small`?

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [March 10, 2025, 4:03pm UTC](https://forum.codecrafters.io/t/dns-server-rust-dns-buffer-size-too-small/6370/4 "2025-03-10T16:03:06Z")

</div>

Hey @roman-barman, the issue is caused by an incorrect `QDCOUNT` value of **2** , even when there is only one question.

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/e/e1f81fd8c819ea2a9138b61309a8125116ad7394.png)

So the bug is here:

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/1/179f0150378a3ae76fa2b098582d671fe18e4370.png)

Let me know if you’d like further clarification!

---

<div class="post-metadata">

**Author:** ![roman-barman](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/roman-barman/32/6526_2.png) [@roman-barman](https://forum.codecrafters.io/u/roman-barman)\
**Post date:** [March 11, 2025, 8:19am UTC](https://forum.codecrafters.io/t/dns-server-rust-dns-buffer-size-too-small/6370/5 "2025-03-11T08:19:09Z")

</div>

Hi @andy1li  
Thank you!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [March 16, 2025, 10:37am UTC](https://forum.codecrafters.io/t/dns-server-rust-dns-buffer-size-too-small/6370/7 "2025-03-16T10:37:57Z")

</div>

Closed on March 16, 2025, 10:37am UTC

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.
