<p>I am deploying kubernetes in Cloud and I'm trying to call another container inside the same pod through an API.</p>
<p>I am using <code>localhost</code> but also I treid with <code>127.0.0.1</code>. Also, I tried with the container's name.</p>
<pre><code>2022/11/04 15:50:47 dial tcp [::1]:4245: connect: connection refused
2022/11/04 15:50:47 Successfully processed file.json file
2022/11/04 15:50:47 Get &quot;http://localhost:4245/api/admin/projects/default&quot;: dial tcp [::1]:4245: connect: connection refused

panic: Get &quot;http://localhost:4245/api/admin/projects/default&quot;: dial tcp [::1]:4245: connect: connection refused
goroutine 1 [running]:
log.Panic({0xc000119dc8?, 0xc000166000?, 0x6aaaea?})
/opt/app-root/src/sdk/go1.19.2/src/log/log.go:388 +0x65
main.StatusServer({0xc000020570?, 0x30?}, {0x0, 0x0})
/build/script.go:197 +0x1ee
main.ProcessData({0xc000020041, 0x15}, {0x0, 0x0}, {0xc00002000f?, 0x43ce05?})
/build/script.go:291 +0xa6
main.main()
/build/script.go:443 +0xc5
</code></pre>
<p>Any idea if I can call the container like that?</p>

X T
<p>You get a connection refused means you reached localhost and it decided to refuse the connection.</p>
<p>This is most likly because nothing is listening on the port.</p>
<p>If it was a firewall issue the request would timeout.</p>
<p>You can check listening ports with command like:</p>
<pre><code>netstat -an
</code></pre>
<p>If not installed maybe you can try it from the workernode where the pod is running.</p>
<p>Another method of testing is to use</p>
<pre><code>curl http://127.0.0.1:4245
</code></pre>
<p>This will probably result in same connection refused.</p>
<p>Are you really sure the container is running in same pod?</p>
<p>Please check your deployment and service.</p>
<p>If you cant find the failure please come back with more information so it can be analysed.</p>
