"Error: Parse Error: Expected HTTP/" when using dns

I have a simple http rest api, which works perfectly when using the ip address directly. I made a dns A record (unproxied) pointing my domain to the ip address, which a traceroute confirms works. However, when using the domain in the browser, an ERR_INVALID_HTTP_RESPONSE error was displayed. Doing the same request in postman showed the error was “Error: Parse Error: Expected HTTP/”. The site still works perfectly with the ip.
The site uses http, I was using http to connect, and encryption mode on Cloudflare was off.

Anyone have an idea why this is occurring?

That seems as if the request or response header was not properly sent.

Would you have a URL as example? If it is unproxied, it won’t be Cloudflare related, as Cloudflare won’t be involved in the request.

a test server where the issue occurs: {removed}

Yeah, it seems to be an issue with the HTTP response and you would need to check out your server code for that. As I mentioned, the record is unproxied, so that response comes straight from your server.

the weird thing is it works perfectly fine when using the ip

With the IP address, it seems to be the same response. But I am afraid, that’s something beyond the scope of the forum here.

hm, odd.
my server uses the builtin sun http server in java, com.sun.net.httpserver.HttpServer.
i dont modify any headers, except Content-Type, setting it to application/json. The method i use to initiate the response (sendResponseHeaders()) actually starts the response with "HTTP/1.1 "+rCode+Code.msg(rCode)+"\r\n", so i really cant explain to myself why it seems to be missing in postman and the browser

You really best debug your code, as you are currently not composing a proper response.

If you need any further assistance, I would recommend to check out StackOverflow or Reddit.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.