404 site not served on this interface

I’m brand new to caddy and have just worked through the beginner tutorial and gotten it to run. I’m now trying to work out the caddyfile.

I have a caddyfile set up with (please forgive the formatting)

localhost:8080
root /home/James/www

The caddyfile is in the www directory and so is a very basic HTML file. I then run caddy directly from the www directory. Then using another computer I type 192.168.1.90:8080 and all I get is a message saying 404 site not served on this interface

What am I doing wrong?

Hi @James_Hewitt, welcome to the Caddy community!

The important thing to note is that, to determine which site definition to use, Caddy checks the server name sent by the client (in this case, what you put in the browser URL bar) against the site label (the first line of your Caddyfile). In your example, localhost doesn’t match 192.168.1.90, and nothing is set up for the latter, hence the “site not served” response.

You could change the first line to 192.168.1.90:8080 instead, which will instruct Caddy to respond to requests for that site. You could alternately omit the name entirely, leaving only the port (i.e. :8080), and it will use that site definition to respond to any HTTP request on port 8080, regardless of site name (so localhost:8080 in your URL bar will get a response locally).

The Structure heading of the Caddyfile documentation is pretty useful, as is the Caddyfile tutorial.

https://caddyserver.com/tutorial/caddyfile


Also, for formatting, you can encapsulate your Caddyfiles with three backticks ( ``` ), like this:

```
localhost:8080
root /home/James/www
```

And it will display in a nice code block.

3 Likes

Thank you so much! It’s working now, or at least I’ve been able to move on a step in my learning! That was bugging me for ages.

2 Likes

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