Bind: Address Already in Use

1. Output of caddy version:

v2.6.2 h1:wKoFIxpmOJLGl3QXoo6PNbYvGW4xLEgo32GPBEjWL8o=

2. How I run Caddy:

The only thing that I’ve changed in caddy is the config file shown below:

a. System environment:

I am running centOS7.

b. Command:

caddy start --config /etc/caddy/Caddyfile

c. Service/unit/compose file:

Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane. -->

d. My complete Caddy config:

node.scottfamilymovers.com {
        reverse_proxy localhost:3006
}

3. The problem I’m having:

I am trying to reverse proxy from my domain: scottfamilymovers.com hosted on Bluehost VPS. SSL/TLS is provided by Bluehost so I don’t know if that matters for caddy connection. The only thing I really need is the reverse proxy I think. All I have done is add the reverse proxy from node.scottfamilymovers.com to localhost:3006 but I receive an error of
address already in use. It seems to give me that error for both ports 80 and 443.

4. Error messages and/or full log output:

root@server.scottfamilymovers.com [WebsiteProject]# caddy start --config /etc/caddy/Caddyfile
2022/12/30 08:22:22.698 INFO    using provided configuration    {"config_file": "/etc/caddy/Caddyfile", "config_adapter": ""}
2022/12/30 08:22:22.703 INFO    admin   admin endpoint started  {"address": "localhost:2019", "enforce_origin": false, "origins": ["//localhost:2019", "//[::1]:2019", "//127.0.0.1:2019"]}
2022/12/30 08:22:22.704 INFO    http    server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS                                                                                                                                                                                                 {"server_name": "srv0", "https_port": 443}
2022/12/30 08:22:22.704 INFO    http    enabling automatic HTTP->HTTPS redirects                                                                                                                                                                                                                                                                {"server_name": "srv0"}
2022/12/30 08:22:22.704 INFO    tls.cache.maintenance   started background certificate maintenance                                                                                                                                                                                                                                              {"cache": "0xc0001bb030"}
2022/12/30 08:22:22.707 INFO    tls.cache.maintenance   stopped background certificate maintenance                                                                                                                                                                                                                                              {"cache": "0xc0001bb030"}
2022/12/30 08:22:22.707 INFO    tls     cleaning storage unit   {"description": "FileStorage:/root/.local/share/caddy"}
2022/12/30 08:22:22.708 INFO    tls     finished cleaning storage units
Error: loading initial config: loading new config: http app module: start: listening on :443: listen tcp :443: bind: address already in use
Error: caddy process exited with error: exit status 1

5. What I already tried:

I haven’t done much as I am very new to both CentOS and Caddy but I did run the below to show connections to ports 80 and 443.

root@server.scottfamilymovers.com [WebsiteProject]# lsof -i :80
COMMAND   PID   USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
httpd   20138 nobody    3u  IPv4 1430796      0t0  TCP *:http (LISTEN)
httpd   20138 nobody    4u  IPv6 1430797      0t0  TCP *:http (LISTEN)
httpd   20141 nobody    3u  IPv4 1430796      0t0  TCP *:http (LISTEN)
httpd   20141 nobody    4u  IPv6 1430797      0t0  TCP *:http (LISTEN)
httpd   20142 nobody    3u  IPv4 1430796      0t0  TCP *:http (LISTEN)
httpd   20142 nobody    4u  IPv6 1430797      0t0  TCP *:http (LISTEN)
httpd   20204   root    3u  IPv4 1430796      0t0  TCP *:http (LISTEN)
httpd   20204   root    4u  IPv6 1430797      0t0  TCP *:http (LISTEN)
httpd   20234 nobody    3u  IPv4 1430796      0t0  TCP *:http (LISTEN)
httpd   20234 nobody    4u  IPv6 1430797      0t0  TCP *:http (LISTEN)
root@server.scottfamilymovers.com [WebsiteProject]# lsof -i :443
COMMAND   PID   USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
httpd   20138 nobody    5u  IPv4 1430798      0t0  TCP *:https (LISTEN)
httpd   20138 nobody    6u  IPv6 1430799      0t0  TCP *:https (LISTEN)
httpd   20141 nobody    5u  IPv4 1430798      0t0  TCP *:https (LISTEN)
httpd   20141 nobody    6u  IPv6 1430799      0t0  TCP *:https (LISTEN)
httpd   20142 nobody    5u  IPv4 1430798      0t0  TCP *:https (LISTEN)
httpd   20142 nobody    6u  IPv6 1430799      0t0  TCP *:https (LISTEN)
httpd   20204   root    5u  IPv4 1430798      0t0  TCP *:https (LISTEN)
httpd   20204   root    6u  IPv6 1430799      0t0  TCP *:https (LISTEN)
httpd   20234 nobody    5u  IPv4 1430798      0t0  TCP *:https (LISTEN)
httpd   20234 nobody    6u  IPv6 1430799      0t0  TCP *:https (LISTEN)

6. Links to relevant resources:

A process called httpd (apache) is listening on those ports (:80 and :443) already.
You will have to stop it first.
I believe the service under CentOS 7 is called httpd, so try

systemctl disable --now httpd

Please use the systemd service and use systemctl start caddy instead.
See Keep Caddy Running — Caddy Documentation

2 Likes

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