Error
Error Code:
240
MongoDB Error 240: Incorrect DNS Record Type
Description
This error indicates that MongoDB encountered a DNS record of an unexpected type when attempting to resolve a hostname. It commonly occurs when using `mongodb+srv://` connection strings and the corresponding SRV record or its underlying A records are misconfigured. The database expects a specific DNS record type (e.g., SRV, A, or AAAA) but finds a different one, preventing successful connection establishment.
Error Message
D N S Record Type Mismatch
Known Causes
4 known causesMisconfigured SRV Record
The SRV record specified in the DNS configuration does not adhere to the expected format, contains incorrect information, or points to an invalid host or port for the MongoDB deployment.
Incorrect A/AAAA Record
The underlying A or AAAA records referenced by an SRV record, or directly queried, do not resolve to the correct MongoDB instance or are themselves of an unexpected type.
Unexpected Record Type Returned
The MongoDB client expects a specific DNS record type (e.g., A record for a direct connection) but the DNS server returns a different, unexpected type (e.g., an SRV record) for the given hostname.
DNS Propagation or Stale Records
Recent changes to DNS records have not fully propagated across DNS servers, or the DNS server being used is caching stale or incorrect record information.
Solutions
Coming SoonGeneral Troubleshooting Tips
- Check the error message carefully for specific details
- Review recent changes that might have caused the error
- Search for the exact error code in the official documentation
- Check log files for additional context
- Try restarting the application or service