Using caddy with ngrok: cannot connect to localhost

I’ve started to use Caddy with the tunnel server service ( that allows a site running on localhost:8080 to be accessible from a custom URL.

I create the tunnel using:

ngrok http localhost:8080

The Caddy server is running on localhost and port 8080. These are the pertinent lines from my Caddyfile:


However, when I try to connect using the URL given to me by the ngrok service, I get the following reply from Caddy when I try to access the web root:

HTTP/1.1 404 Not Found
Content-Type: text/plain; charset=utf-8
Server: Caddy
X-Content-Type-Options: nosniff
Date: Tue, 28 Mar 2017 17:24:11 GMT
Content-Length: 21
No such site at :8080

What is going on here, and why can’t I access localhost using the webroot?

By the way, the same return code from the server (“No such site at :8080”) is also returned when I use the service.

I am running Linux on my development machine (Linux Laura 4.4.0-67-generic #88-Ubuntu SMP Wed Mar 8 16:34:45 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux).

Probably because the Host header of the request isn’t “localhost”. Remove that from your site definition in the Caddyfile and try again.


Matt, thank you for your response.

In my Caddyfile, I tried to replace the line



[ip address]:8080

where [ip address] is my current IP address, but this did not work.

Could you clarify how I can remove the “localhost” from the site definition? I have also tried, but the same problem is apparent. That is, in my Caddyfile:

This is the only line that I have in my file for the site definition. Is something else required?

try with just


this will respond to any requests on port 8080


Great - thanks so much Toby and Matt for the quick response. This works well!

Thanks again!

1 Like

Yeah, like literally remove it, don’t put any host in there…

1 Like

Yes, this works well - thanks Matt!

Oops, I saw after the fact that Toby already answered perfectly! Stupid internet connection.

To shed some light on why that happened:

When a client accesses Caddy via, Caddy will look for server configuration for, which it doesn’t have (because it was configured for localhost, then your IP address).

By changing the Caddyfile to :8080, Caddy will serve that configuration to any host, localhost, your IP,, or, because it is essentially a wildcard host. In this case, using would also work, but then you would get 404s if you tried to access it locally in the browser via localhost:8080.


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