<p>So I've been struggling with this all afternoon. I can't at all get my NodeJS application running on kubernetes to connect to my MongoDB Atlas database.</p>
<p>In my application I've tried running</p>
<pre><code>mongoose.connect('mongodb+srv://admin:&lt;password&gt;@&lt;project&gt;.gcp.mongodb.net/project_prod?retryWrites=true&amp;w=majority', { useNewUrlParser: true })
</code></pre>
<p>but I simply get the error</p>
<pre><code>UnhandledPromiseRejectionWarning: Error: querySrv ETIMEOUT _mongodb._tcp.&lt;project&gt;.gcp.mongodb.net
    at QueryReqWrap.onresolve [as oncomplete] (dns.js:196:19)
(node:32) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 17)
</code></pre>
<p>I've tried setting up a ExternalName service too, but using either the URL or the ExternalName results in me not being able to connect to the database.</p>
<p>I've whitelisted my IP on MongoDB Atlas, so I know that isn't the issue.</p>
<p>It also seems to work on my local machine, but not in the kubernetes pod. What am I doing wrong?</p>

Matthew Weeks
<p>I figured out the issue, my pod DNS was not configured to allow external connections, so I set <code>dnsPolicy: Default</code> in my YML, because oddly enough <code>Default</code> is not actually the default value</p>
