0

I set up a rest service with the grapevine, plus I'm having trouble accessing remotely even with the firewall turned off.

Are you only accepting connections through localhost or 127.0.0.1, when I try to access the IP of the machine or remotely gives this error

Bad Request - Invalid Hostname HTTP Error 400. The request hostname is invalid.

using (var server = new RestServer())
{
    server.Port = "9999";
    server.LogToConsole().Start();
    Console.ReadLine();
    server.Stop();
}
Elvis Reis
  • 155
  • 4
  • 12

1 Answers1

3

Edit: Please refer to the (updated) documentation, specifically the page On Using HttpListener


The current default value is localhost. You can change the directly using the Host property:

server.Host = "*";

Use "*" to indicate that the HttpListener accepts requests sent to the port if the requested URI does not match any other prefix. Similarly, to specify that the HttpListener accepts all requests sent to a port, replace the host element with the "+" character.

So, for Grapevine 4, you could write your code as follows:

using (var server = new RestServer{Port = "9999", Host = "*"})
{
    server.LogToConsole().Start();
    Console.ReadLine();
    server.Stop();
}
Scott Offen
  • 6,933
  • 3
  • 21
  • 24
  • Can you please help me here? I have this same issue. I am on VB.NET. I also get http error 400 when trying to connect from a diffferent machine. I added server.host = "*", but this results in a "UnableToStartHostExceprion". I also tried server.host = "*". But with the same result. – Richard Lleram Jun 24 '20 at 22:18