Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

My curl POST gets "Empty reply from server"

Tags:

curl

ubuntu

kong

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?

like image 206
efe Avatar asked Dec 22 '16 19:12

efe


People also ask

How do I fix curl 52 empty response from server?

Causes and Fixes for curl (52) empty reply from server Cause: Something in the network/setup is preventing this from working, like a firewall. Fix: We check the firewall rules and ensure that HTTP, HTTPS, required ports and services are enabled in the firewall. To run scheduled events, we use Loopback requests.

What causes Empty reply from server?

The "empty reply from server" error indicates that a zero length response was received - no HTTP headers or content, simply a closed TCP connection with no HTTP payload transmitted. One common cause of this problem is attempting to make a plain HTTP request against the HTTPS (TLS / SSL) web server port.

Why is curl not working?

This type of error comes due to only one reason: the relevant package is not installed. Curl is a very popular data transfer command-line utility used for downloading and uploading data from or to the server. It used various network protocols for uploading and downloading data like HTTP, HTTPS, FTP, and SFTP.

What does it mean when curl hangs?

The curl problem could have various reasons that require a user input, for example an untrusted certificate that is stored in the trusted certificates cache of the root user, but not the PHP one. In that case, the command would be waiting for an input that never happens.


1 Answers

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!

like image 129
Daniel Stenberg Avatar answered Oct 14 '22 06:10

Daniel Stenberg