My curl POST gets "Empty reply from server"

28.1k views Asked by At

I am following this guide:

http://lua-programming.blogspot.co.uk/

I am at the part where I need to create my API. I have used kong before and have created a script to make an api. The problem is that I cannot create an API. My script is literally a barebone api which has no plugins (want to create an api first):

curl -X POST --url http://localhost:8001/apis/ --data 'name=mock' --data 'upstream_url=https://mockbin.com' --data 'request_host=mockbin.com';

Whenever I run this command, I get a curl: (52) Empty reply from server error but when I do curl -X GET --url http://localhost:8001/apis, it tells me how much apis I have currently (which is 0) so surely there is nothing wrong with the server, right?

Ive installed cassandra and kong locally. Any ideas?

2

There are 2 answers

0
Daniel Stenberg On

When you get error 52 back, it literally means "Empty reply from server". When a client (like curl) speaks HTTP to a server, that server must send something back for it to be legitimate HTTP. Protocol-wise, there is no way to be compliant and not respond anything.

Error 52 means the server did just that. It didn't respond with a single byte of data (and then closed the connection). No server in good health should ever do this.

Sometimes you can trigger this action by a server when you happen to send something that the server doesn't like, but it is nonetheless a server problem. Those times you may be able to avoid this error by not sending whatever it is that triggers the server error, but that can be hard or even very hard to figure out.

The most common cause for this problem is when there's not actually a HTTP server listening on the given host or port number!

0
Arvind suresh On

in my case i returned two responses in the same condition i removed one and it worked fine hope it does the same for you!