Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bind: cannot assign requested address #44

Closed
git-Charlie opened this issue Mar 10, 2020 · 11 comments
Closed

bind: cannot assign requested address #44

git-Charlie opened this issue Mar 10, 2020 · 11 comments

Comments

@git-Charlie
Copy link

git-Charlie commented Mar 10, 2020

centos7 , docker cmd:

 docker run --rm  -v /root/caddy:/config caddy/caddy

print logs


2020/03/10 17:21:28.594	INFO	using provided configuration	{"config_file": "/etc/caddy/Caddyfile", "config_adapter": "caddyfile"}
run: loading initial config: loading new config: starting caddy administration endpoint: listen tcp 37.152.88.55:2019: bind: cannot assign requested address

  • the 37.152.... is not my IP address,
  • I am test 4 server,
    • CentOS Linux release 7.6.1810 (Core) / Docker version 18.09.0, build 4d60db4 OK
    • CentOS Linux release 7.7.1908 (Core) / Docker version 19.03.5, build 633a0ea
      Error x2
    • Winddows 10 Docker version 19.03.5, build 633a0ea OK
@git-Charlie
Copy link
Author

git-Charlie commented Mar 10, 2020

I am use global options block -> admin off ,
the problem was covered up

@hairyhenderson
Copy link
Contributor

@git-Charlie I'm not sure why this'd be happening. What is the contents of /root/caddy when you start? is it empty?

@hairyhenderson
Copy link
Contributor

When I run the same command, with an empty config mount, I see:

$ docker run --rm  -v $(pwd)/config:/config caddy/caddy
2020/03/11 01:44:27.150	INFO	using provided configuration	{"config_file": "/etc/caddy/Caddyfile", "config_adapter": "caddyfile"}
2020/03/11 01:44:27.154	INFO	admin	admin endpoint started	{"address": "localhost:2019", "enforce_origin": false, "origins": ["localhost:2019"]}
2020/03/11 01:44:27.155	INFO	http	server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server	{"server_name": "srv0", "http_port": 80}
2020/03/11 01:44:27.155	INFO	tls	cleaned up storage units
2020/03/11 01:44:27.156	INFO	autosaved config	{"file": "/config/caddy/autosave.json"}
2020/03/11 01:44:27.156	INFO	serving initial configuration

@mholt
Copy link
Member

mholt commented Mar 11, 2020

Somehow localhost is resolving to 37.152.88.55?

@git-Charlie
Copy link
Author

When I run the same command, with an empty config mount, I see:

$ docker run --rm  -v $(pwd)/config:/config caddy/caddy
2020/03/11 01:44:27.150	INFO	using provided configuration	{"config_file": "/etc/caddy/Caddyfile", "config_adapter": "caddyfile"}
2020/03/11 01:44:27.154	INFO	admin	admin endpoint started	{"address": "localhost:2019", "enforce_origin": false, "origins": ["localhost:2019"]}
2020/03/11 01:44:27.155	INFO	http	server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server	{"server_name": "srv0", "http_port": 80}
2020/03/11 01:44:27.155	INFO	tls	cleaned up storage units
2020/03/11 01:44:27.156	INFO	autosaved config	{"file": "/config/caddy/autosave.json"}
2020/03/11 01:44:27.156	INFO	serving initial configuration

image

same error

@git-Charlie
Copy link
Author

Somehow localhost is resolving to 37.152.88.55?

I don't think so ,
this is check step:

docker run -itd  caddy/caddy /bin/sh
# display like xxxxxx Container id
docker attach xxxxx
# attach to container
ping localhost

PING localhost (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: seq=0 ttl=64 time=0.087 ms
64 bytes from 127.0.0.1: seq=1 ttl=64 time=0.121 ms
64 bytes from 127.0.0.1: seq=2 ttl=64 time=0.105 ms
64 bytes from 127.0.0.1: seq=3 ttl=64 time=0.111 ms
64 bytes from 127.0.0.1: seq=4 ttl=64 time=0.172 ms
^C
--- localhost ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max = 0.087/0.119/0.172 ms


@git-Charlie
Copy link
Author

git-Charlie commented Mar 11, 2020

I'm sure only a specific VPS provider has this problem (2 recently purchased VPS in same DC area).
But according to my understanding, shouldn't docker avoid this problem?
And I use the SSH connect to Vps Ping localhost , and the result is also 127.0.0.1

@git-Charlie
Copy link
Author

git-Charlie commented Mar 11, 2020

I have a new discovery

ping localhost.es
PING localhost.es (37.152.88.55) 56(84) bytes of data.
64 bytes from parkingsrv0.dondominio.com (37.152.88.55): icmp_seq=1 ttl=54 time=165 ms
64 bytes from parkingsrv0.dondominio.com (37.152.88.55): icmp_seq=2 ttl=54 time=165 ms
64 bytes from parkingsrv0.dondominio.com (37.152.88.55): icmp_seq=3 ttl=54 time=164 ms

The hostname my VPS is xxx.es and yyy.es

In vps vim /etc/resolv.conf
remove line of search es
the problem is solved

@mholt
Copy link
Member

mholt commented Mar 11, 2020

Aye, that would do it; a misconfigured machine. Thanks for posting the solution!

@mholt mholt closed this as completed Mar 11, 2020
@fabianlaule
Copy link

@mholt I'm a little bit confused why caddy automatically searches for "localhost" on the search path found in /etc/resolv.conf (as example mysearchpath.example.com) and tries to resolve it (so it tries localhost.mysearchpath.example.com). I ran today in the same issue and have never seen this behaviour in other tools.

@mholt
Copy link
Member

mholt commented Apr 24, 2020

I'm not sure; you'll have to ask the Go std lib maintainers or dig into the standard library to find the answer. Let us know what you find!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants