Unable to get caddy working in browser

1. The problem I’m having:

I have a fresh install of Raspbian Bookworm and Caddy is the first thing I’ve installed on it. I have yet to get caddy to serve anything through a web browser, even a simple respond message. I can curl and get a good response however. I’ve been messing with it for hours and just don’t get where the problem is.

2. Error messages and/or full log output:

curl -vL https://localhost:2015

*   Trying 127.0.0.1:2015...
* Connected to localhost (127.0.0.1) port 2015 (#0)
* ALPN: offers h2,http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
*  CAfile: /etc/ssl/certs/ca-certificates.crt
*  CApath: /etc/ssl/certs
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_CHACHA20_POLY1305_SHA256
* ALPN: server accepted h2
* Server certificate:
*  subject: [NONE]
*  start date: Aug 11 00:14:59 2024 GMT
*  expire date: Aug 11 12:14:59 2024 GMT
*  subjectAltName: host "localhost" matched cert's "localhost"
*  issuer: CN=Caddy Local Authority - ECC Intermediate
*  SSL certificate verify ok.
* using HTTP/2
* h2h3 [:method: GET]
* h2h3 [:path: /]
* h2h3 [:scheme: https]
* h2h3 [:authority: localhost:2015]
* h2h3 [user-agent: curl/7.88.1]
* h2h3 [accept: */*]
* Using Stream ID: 1 (easy handle 0x558ca167c0)
> GET / HTTP/2
> Host: localhost:2015
> user-agent: curl/7.88.1
> accept: */*
>
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
< HTTP/2 200
< alt-svc: h3=":2015"; ma=2592000
< content-type: text/plain; charset=utf-8
< server: Caddy
< content-length: 5
< date: Sun, 11 Aug 2024 01:27:21 GMT
<
* Connection #0 to host localhost left intact

From any web browser I get

Hmmm… can’t reach this page

localhost refused to connect.

Try:

  • Checking the connection
  • [Checking the proxy and the firewall]

ERR_CONNECTION_REFUSED

3. Caddy version:

v2.8.4

4. How I installed and ran Caddy:

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy

I am running it as a background service. Not opposed to running as systemd though.

sudo caddy start --config /etc/caddy/Caddyfile

a. System environment:

Distributor ID: Debian
Description: Debian GNU/Linux 12 (bookworm)
Release: 12
Codename: bookworm

b. Command:

sudo caddy start --config /etc/caddy/Caddyfile

c. Service/unit/compose file:

PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

d. My complete Caddy config:

localhost:2015

respond "hello"

5. Links to relevant resources:

Just to start with the obvious:

You’re definitely running the web browser on the same machine you’re running Caddy on, right? (So localhost points at itself.)

And in your browser, you’re definitely typing out the full https://localhost:2015 (including scheme and port number) in the address bar, yeah?

2 Likes

Probably a mixture of things but I was definitely confusing localhost with the device ip on the network 192.168.1.29. I was using ssh from a laptop to the device but trying to use localhost in the browser. :man_facepalming:

1 Like

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