Home > Mobile >  Connection refused when deploying in cloud on kubernetes
Connection refused when deploying in cloud on kubernetes

Time:11-05

I am deploying kubernetes in Cloud and I'm trying to call another container inside the same pod through an API.

I am using localhost but also I treid with 127.0.0.1. Also, I tried with the container's name.

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 "http://localhost:4245/api/admin/projects/default": dial tcp [::1]:4245: connect: connection refused

panic: Get "http://localhost:4245/api/admin/projects/default": 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

Any idea if I can call the container like that?

CodePudding user response:

You get a connection refused means you reached localhost and it decided to refuse the connection.

This is most likly because nothing is listening on the port.

If it was a firewall issue the request would timeout.

You can check listening ports with command like:

netstat -an

If not installed maybe you can try it from the workernode where the pod is running.

Another method of testing is to use

curl http://127.0.0.1:4245

This will probably result in same connection refused.

Are you really sure the container is running in same pod?

Please check your deployment and service.

If you cant find the failure please come back with more information so it can be analysed.

  • Related