Skip to content
Guy McSwain edited this page Jan 14, 2020 · 11 revisions

Known Issues with Work-Arounds

"socket connect failed" but only if starting pigpiod via systemctl #203

UPDATE: Resolved with upgrade to pigpio V73.

The '-l' option on pigpiod is intended to allow localhost only connection to the daemon. The Raspbian distribution uses localhost only option in /lib/systemd/system/pigpiod.service, presumably for security reasons.

After basic support for IPv6 was introduced in pigpio, (circa V61), the '-l' option binds exclusively to the IPv6 loopback address '::1'.

To circumvent connection failures from clients attempting to connect with IPv4 localhost (127.0.0.1), the daemon must be started using the '-n' option with the IPv4 localhost address. To do so with systemd, patch the pigpiod.service file as follows:

# delete
ExecStart=/usr/bin/pigpiod -l
# add
ExecStart=/usr/bin/pigpiod -n 127.0.0.1

Example clients connecting to pigpiod

(starting from a fresh Raspbian install)

$ sudo apt-get install pigpio python-pigpio
$ sudo systemctl start pigpiod
$ pigs hwver
socket connect failed
# pigs fails to connect using IPv4
$ python -c "import pigpio; pi=pigpio.pi(); exit()"
# python client connects successfully
$ sudo systemctl stop pigpiod
$ python -c "import pigpio; pi=pigpio.pi(); exit()"
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Can't connect to pigpio at localhost(8888)

Did you start the pigpio daemon? E.g. sudo pigpiod

Did you specify the correct Pi host/port in the environment
variables PIGPIO_ADDR/PIGPIO_PORT?
E.g. export PIGPIO_ADDR=soft, export PIGPIO_PORT=8888

Did you specify the correct Pi host/port in the
pigpio.pi() function? E.g. pigpio.pi('soft', 8888)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Python can't connect because the daemon isn't running.
$ sudo pigpiod -n 127.0.0.1
$ pigs hwver
10494163
# pigs is now connecting to the daemon.
$ python -c "import pigpio; pi=pigpio.pi(); exit()"
# python client connects using '127.0.0.1' also.

Pigpio cant connect to localhost(8888) #195

Similar issue and W/A as #203 above.

UPDATE: Resolved with upgrade to pigpio V73.

Clone this wiki locally