'server www' : could not resolve address 'www'

Hi all,

I was trying to find something similar but this question does not seem to be answered before, sorry if I didnt find it.

I am deploying with docker machine a haproxy configuration that includes letsencrypt for two subdomains. I got these errors:

haproxy |<7>haproxy-systemd-wrapper: executing /usr/local/sbin/haproxy -p /run/haproxy.pid -f /usr/local/etc/haproxy/haproxy.cfg -Ds
haproxy | [ALERT] 302/150350 (26) : parsing [/usr/local/etc/haproxy/haproxy.cfg:31] : ‘server www’ : could not resolve address ‘www’.
haproxy | [ALERT] 302/150350 (26) : Failed to initialize server(s) addr.
haproxy | <5>haproxy-systemd-wrapper: exit, haproxy RC=1
haproxy | <7>haproxy-systemd-wrapper: executing /usr/local/sbin/haproxy -p /run/haproxy.pid -f /usr/local/etc/haproxy/haproxy.cfg -Ds
haproxy | [ALERT] 302/150352 (29) : parsing [/usr/local/etc/haproxy/haproxy.cfg:31] : ‘server www’ : could not resolve address ‘www’.
haproxy | [ALERT] 302/150352 (29) : Failed to initialize server(s) addr.
haproxy | <5>haproxy-systemd-wrapper: exit, haproxy RC=1
haproxy | <7>haproxy-systemd-wrapper: executing /usr/local/sbin/haproxy -p /run/haproxy.pid -f /usr/local/etc/haproxy/haproxy.cfg -Ds
haproxy | [ALERT] 302/150355 (32) : parsing [/usr/local/etc/haproxy/haproxy.cfg:31] : ‘server www’ : could not resolve address ‘www’.
haproxy | [ALERT] 302/150355 (32) : Failed to initialize server(s) addr.
haproxy | <5>haproxy-systemd-wrapper: exit, haproxy RC=1

This is the configuration (Sorry for the formatting):

global
maxconn 256
lua-load /usr/local/etc/haproxy/acme-http01-webroot.lua
chroot /jail
ssl-default-bind-ciphers AES256+EECDH:AES256+EDH:!aNULL;
tune.ssl.default-dh-param 4096

defaults
mode http
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
option forwardfor
option http-server-close
stats enable
stats uri /stats
stats realm Haproxy\ Statistics
stats auth XXX:XXX

frontend ft_ssl_vip
bind *:443 ssl crt /usr/local/etc/haproxy/certs/ no-sslv3 no-tls-tickets no-tlsv10 no-tlsv11

rspadd Strict-Transport-Security:\ max-age=15768000

# Database redirect from subdomain [alexandrie]
acl db_match_acl      hdr_end(host) -i subdomainA.domain.com
use_backend db_server if db_match_acl

# Testing server redirect from subdomain [meduse]
acl apptest_match_acl      hdr_end(host) -i subdomainB.domain.com
use_backend apptest_server if apptest_match_acl

backend db_server
server db_server XXX.XXX.XXX.XXX:80 check
http-request add-header X-Forwarded-Proto https if { ssl_fc }

backend apptest_server
server apptest_server XXX.XXX.XXX.XXX:80 check
http-request add-header X-Forwarded-Proto https if { ssl_fc }

What I am missing?
Thanks in advance for your support!
HAProxy is great!!!

You configured haproxy do access the server www but it cannot be resolved.

Thank you for your answer.

Can you please explain me how to fix it? I don’t know how I configured haproxy to “do access the server www”. My configuration is above. Is there anything else I am missing?

Thanks again!

I don’t know how to fix it, you did not explain what you are trying to do. You also replaced the most relevant part of the configuration with XXX.XXX.XXX.XXX:80 in the configuration above, among other things that make me think the configuration you posted here is NOT the configuration that runs.

Please post the real configuration file you are using, and explain what destination server you are trying to connect to.

Thanks lukastribus.

So I have three servers:

  • a proxy server with haproxy running in it with the above haproxy.conf The conf is the full conf, I am quite new to haproxy so when you say some parts are missing maybe I am missing important things in my conf above?

  • Two other servers are behind this proxy in a private network. One is the db and the other is the backend. The proxy server provides access to the internet and make all the request HTTPS with the rest of the world. So once a request arrive to the proxy, the request is routed either to the db server or the backend server. All the SSL is then configured only at the proxy level.

The IPs above are different between them an irrelevant for this problem as they belong to the aforementioned private network.

The proxy server is a docker machine with haproxy and letsencrypt support. Everything seems fine except that I get the errors above.

Thank you again for your support!!

EDIT: To clarify, the idea is that the two servers in the private network can be accessed through their subdomains (e.g. subdomainA.domain.com) but these requests pass through the proxy so all of them are HTTPS.

The log message says:

That means, in your configuration file at:
/usr/local/etc/haproxy/haproxy.cfg

On line 31 there is a reference to a “server www” with destination “www”, and the hostname www cannot be resolved.

The configuration you posted does not even contain any “server www”, let alone the www destination. It contains only XXX.XXX.XXX.XXX:80.

Maybe you are working on a different configuration file? Check the paths.

1 Like