HAProxy doesn't start, can not bind UNIX socket [/run/haproxy/admin.sock]
Asked Answered
T

5

37

I'm trying to start haproxy (version 1.5.8 2014/10/31) with an "empty" config file and I get:

user@server:~$ sudo service haproxy start
[....] Starting haproxy: haproxy[ALERT] 126/120540 (7363) : Starting frontend GLOBAL: cannot bind UNIX socket [/run/haproxy/admin.sock]

altough it's enabled:

user@server:~$ cat /etc/default/haproxy 
# Set ENABLED to 1 if you want the init script to start haproxy.
ENABLED=1

Configuration file:

global
    log /dev/log    local0
    log /dev/log    local1 notice
    chroot /var/lib/haproxy
    stats socket /run/haproxy/admin.sock mode 660 level admin
    stats timeout 30s
    user haproxy
    group haproxy
    daemon

    # Default SSL material locations
    ca-base /etc/ssl/certs
    crt-base /etc/ssl/private

    # Default ciphers to use on SSL-enabled listening sockets.
    # For more information, see ciphers(1SSL).
    ssl-default-bind-ciphers kEECDH+aRSA+AES:kRSA+AES:+AES256:RC4-SHA:!kEDH:!LOW:!EXP:!MD5:!aNULL:!eNULL
    ssl-default-bind-options no-sslv3

defaults
    log     global
    mode    http
    option  httplog
    option  dontlognull
    timeout connect 5000
    timeout client  50000
    timeout server  50000
    errorfile 400 /etc/haproxy/errors/400.http
    errorfile 403 /etc/haproxy/errors/403.http
    errorfile 408 /etc/haproxy/errors/408.http
    errorfile 500 /etc/haproxy/errors/500.http
    errorfile 502 /etc/haproxy/errors/502.http
    errorfile 503 /etc/haproxy/errors/503.http
    errorfile 504 /etc/haproxy/errors/504.http

Does anyone have an idea why it can't start?

Talkfest answered 7/5, 2015 at 12:26 Comment(2)
If I remove: "stats socket /run/haproxy/admin.sock mode 660 level admin \ stats timeout 30s", it can startTalkfest
Could someone explain why?Talkfest
L
77

Haproxy needs to write to /run/haproxy/admin.sock but it wont create the directory for you. Create the directory /run/haproxy/ first or set stats socket to a different path.

Lowder answered 27/10, 2015 at 2:35 Comment(2)
Wow spent like 4 hours on this issue. Ta!Petepetechia
Thanks @Lowder i was struggling for this issue for whole day and your answer solved my problemDegrease
V
3

I ran into this problem and had to remove the /run/haproxy/admin.sock file for HAProxy to restart successfully. I can only think it became corrupted after I aborted a yum update command. Oops! 😅

Volatile answered 27/3, 2017 at 19:24 Comment(1)
Been getting nowhere for days now. Deleting this file caused some movement. ThanksKaput
C
1

After updating pfSense from 2.4.5 to 2.5.2 I was facing this issue. As @datacarl said, using command mkdir -p /run/haproxy/ from pfSense CLI works great.

Catechin answered 14/10, 2021 at 22:14 Comment(0)
F
1

A systemd service/program can't create its own folder / runtime .pid file in /run directory and refuse to start without the folder to write to?

You can add this line in your systemd service file, this line will enable the systemd service to automatically create the required folder during runtime and let the app write into it (and will remove the folder when it stopped) :

RuntimeDirectory=haproxy

Then:

sudo systemctl daemon-reload
sudo systemctl restart haproxy
Fluidextract answered 9/4, 2023 at 0:17 Comment(0)
G
0

Couple things with this. Know not the newest convo.

Anything i create in the /run folder disappears after reboot. If I move to /var/lib/haproxy rather than /run/haproxy it starts fine manually as root. If I reboot it fails. Not sure if it's because it's trying to use haproxy on reboot? if I su haproxy it says the account isn't available but think that's because it's set to nologin.

Gurkha answered 27/9, 2020 at 23:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.