Why am I getting an ’empty reply from server’ when curling my API?

0
4
Asked By CuriousCoder123 On

Hey everyone! I'm in a bit of a bind here and would really appreciate your insights. I have a pod running a small REST API, and I've set it up to listen on port 5000, which is configured correctly on the container. Plus, I created a ClusterIP service that points to the same port. The good news is that I can successfully make RESTful requests to my API through localhost:5000 when I port forward the pod. However, when I exec into the pod and try to curl the same endpoint, I get an 'empty reply from server' error. I even tried using a separate test pod running nginx and attempted to curl the API pod using its service name, but I got the same error. Any thoughts or suggestions on what might be going wrong? Thanks in advance!

2 Answers

Answered By ShellSeeker44 On
Answered By TechSavant9 On

It sounds like you're trying to access the API from within the same pod, right? If that's the case, and you can't curl 127.0.0.1 or localhost from there, then it likely isn't a Kubernetes issue—there might be something off with your application itself. It's odd that port forwarding works, though. You should check to see which IPs your API is listening on. I recommend trying to set it to 0.0.0.0 so it listens on all interfaces.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.