# Connection refused error while programming zcu-104

**URL:** <https://discuss.pynq.io/t/connection-refused-error-while-programming-zcu-104/2632>\
**Category:** Support\
**Created:** [May 7, 2021, 5:06pm UTC](https://discuss.pynq.io/t/connection-refused-error-while-programming-zcu-104/2632 "2021-05-07T17:06:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![stebosisio](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@stebosisio](https://discuss.pynq.io/u/stebosisio)\
**Post date:** [May 7, 2021, 5:06pm UTC](https://discuss.pynq.io/t/connection-refused-error-while-programming-zcu-104/2632/1 "2021-05-07T17:06:43Z")

</div>

Hi All,

I have a zcu-104 board with pynq image on it, and I normally program it with a script that goes through the following steps (copied from Jupiter examples):

import sys  
sys.path.append(“/home/xilinx/pynq”)  
from random import randint  
from pynq import MMIO  
from pynq import PL  
from pynq import Overlay  
from pynq import Interrupt  
import os

bspath = ‘bitfiles/’  
PL = Overlay(bspath + ‘bistream.bit’ )

Everything worked ok till few days ago when I last programmed the board.  
Today at PL = Overlay(bspath + ‘bistream.bit’ ) I’m facing this:

Traceback (most recent call last):  
File “”, line 1, in   
File “/usr/local/lib/python3.6/dist-packages/pynq/overlay.py”, line 315, in **init**  
self.download()  
File “/usr/local/lib/python3.6/dist-packages/pynq/overlay.py”, line 379, in download  
super().download()  
File “/usr/local/lib/python3.6/dist-packages/pynq/pl.py”, line 1938, in download  
PL.shutdown()  
File “/usr/local/lib/python3.6/dist-packages/pynq/pl.py”, line 1458, in shutdown  
ip = cls.ip\_dict  
File “/usr/local/lib/python3.6/dist-packages/pynq/pl.py”, line 1297, in ip\_dict  
cls.client\_request()  
File “/usr/local/lib/python3.6/dist-packages/pynq/pl.py”, line 1416, in client\_request  
cls.\_remote = Client(address, family=‘AF\_UNIX’, authkey=key)  
File “/usr/lib/python3.6/multiprocessing/connection.py”, line 487, in Client  
c = SocketClient(address)  
File “/usr/lib/python3.6/multiprocessing/connection.py”, line 614, in SocketClient  
s.connect(address)  
ConnectionRefusedError: [Errno 111] Connection refused  
Error in sys.excepthook:  
Traceback (most recent call last):  
File “/usr/lib/python3/dist-packages/apport\_python\_hook.py”, line 63, in apport\_excepthook  
File “/usr/lib/python3/dist-packages/apport/ **init**.py”, line 5, in   
from apport.report import Report  
File “”, line 971, in \_find\_and\_load  
File “”, line 955, in \_find\_and\_load\_unlocked  
File “”, line 665, in \_load\_unlocked  
File “”, line 674, in exec\_module  
File “”, line 779, in get\_code  
File “”, line 487, in \_compile\_bytecode  
ValueError: bad marshal data (unknown type code)

Original exception was:  
Traceback (most recent call last):  
File “”, line 1, in   
File “/usr/local/lib/python3.6/dist-packages/pynq/overlay.py”, line 315, in **init**  
self.download()  
File “/usr/local/lib/python3.6/dist-packages/pynq/overlay.py”, line 379, in download  
super().download()  
File “/usr/local/lib/python3.6/dist-packages/pynq/pl.py”, line 1938, in download  
PL.shutdown()  
File “/usr/local/lib/python3.6/dist-packages/pynq/pl.py”, line 1458, in shutdown  
ip = cls.ip\_dict  
File “/usr/local/lib/python3.6/dist-packages/pynq/pl.py”, line 1297, in ip\_dict  
cls.client\_request()  
File “/usr/local/lib/python3.6/dist-packages/pynq/pl.py”, line 1416, in client\_request  
cls.\_remote = Client(address, family=‘AF\_UNIX’, authkey=key)  
File “/usr/lib/python3.6/multiprocessing/connection.py”, line 487, in Client  
c = SocketClient(address)  
File “/usr/lib/python3.6/multiprocessing/connection.py”, line 614, in SocketClient  
s.connect(address)  
ConnectionRefusedError: [Errno 111] Connection refused

This happens always: by running the script, by doing step by step manually, by connection to the board via ssh, by using the terminal.  
Apparently nothing has been changed on the board till the last time it was programmed successfully. Any idea of what is happening?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![PeterOgden](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/peterogden/32/55_2.png) [@PeterOgden](https://discuss.pynq.io/u/PeterOgden)\
**Post date:** [May 10, 2021, 8:07am UTC](https://discuss.pynq.io/t/connection-refused-error-while-programming-zcu-104/2632/2 "2021-05-10T08:07:12Z")

</div>

It looks like the PL server is failing to start. Can you run `sudo systemctl status pl_server` and `sudo journalctl -u pl_server.service` and see if there is any information there as to why?

Peter

---

<div class="post-metadata">

**Author:** ![stebosisio](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@stebosisio](https://discuss.pynq.io/u/stebosisio)\
**Post date:** [May 10, 2021, 9:33am UTC](https://discuss.pynq.io/t/connection-refused-error-while-programming-zcu-104/2632/3 "2021-05-10T09:33:47Z")

</div>

Yes you are right. Here what I found:

> systemctl status pl\_server â pl\_server.service - PYNQ PL Server  
> Loaded: loaded (/lib/systemd/system/pl\_server.service; enabled; vendor preset: enabled)  
> Active: failed (Result: exit-code) since Mon 2021-05-10 12:35:23 CEST; 1h 10min left  
> Process: 3261 ExecStart=/usr/local/bin/pl\_server.sh (code=exited, status=0/SUCCESS)  
> Main PID: 3262 (code=exited, status=1/FAILURE)  
> May 10 12:35:23 pynq pl\_server.sh[3261]: line = next(iter(version\_lines), ‘’)  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 2627, in \_get\_metadata  
> May 10 12:35:23 pynq pl\_server.sh[3261]: for line in self.get\_metadata\_lines(name):  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 1408, in get\_metadata\_lines  
> May 10 12:35:23 pynq pl\_server.sh[3261]: return yield\_lines(self.get\_metadata(name))  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 1405, in get\_metadata  
> May 10 12:35:23 pynq pl\_server.sh[3261]: return value.decode(‘utf-8’) if six.PY3 else value  
> May 10 12:35:23 pynq pl\_server.sh[3261]: UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xd6 in position 9: invalid continuation byte  
> May 10 12:35:23 pynq systemd[1]: pl\_server.service: Main process exited, code=exited, status=1/FAILURE  
> May 10 12:35:23 pynq systemd[1]: pl\_server.service: Failed with result ‘exit-code’.

and

> sudo journalctl -u pl\_server.service  
> – Reboot –  
> May 10 12:35:20 pynq systemd[1]: Starting PYNQ PL Server…  
> May 10 12:35:21 pynq systemd[1]: Started PYNQ PL Server.  
> May 10 12:35:23 pynq pl\_server.sh[3261]: Traceback (most recent call last):  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/local/bin/start\_pl\_server.py”, line 6, in   
> May 10 12:35:23 pynq pl\_server.sh[3261]: from pkg\_resources import load\_entry\_point  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 3088, in   
> May 10 12:35:23 pynq pl\_server.sh[3261]: @\_call\_aside  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 3072, in \_call\_aside  
> May 10 12:35:23 pynq pl\_server.sh[3261]: f(\*args, \*\*kwargs)  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 3101, in \_initialize\_master\_working\_set  
> May 10 12:35:23 pynq pl\_server.sh[3261]: working\_set = WorkingSet.\_build\_master()  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 565, in \_build\_master  
> May 10 12:35:23 pynq pl\_server.sh[3261]: ws = cls()  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 558, in **init**  
> May 10 12:35:23 pynq pl\_server.sh[3261]: self.add\_entry(entry)  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 614, in add\_entry  
> May 10 12:35:23 pynq pl\_server.sh[3261]: for dist in find\_distributions(entry, True):  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 1964, in find\_on\_path  
> May 10 12:35:23 pynq pl\_server.sh[3261]: for dist in factory(fullpath):  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 2034, in distributions\_from\_metadata  
> May 10 12:35:23 pynq pl\_server.sh[3261]: root, entry, metadata, precedence=DEVELOP\_DIST,  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 2473, in from\_location  
> May 10 12:35:23 pynq pl\_server.sh[3261]: py\_version=py\_version, platform=platform, \*\*kw  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 2835, in \_reload\_version  
> May 10 12:35:23 pynq pl\_server.sh[3261]: md\_version = \_version\_from\_file(self.\_get\_metadata(self.PKG\_INFO))  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 2437, in \_version\_from\_file  
> May 10 12:35:23 pynq pl\_server.sh[3261]: line = next(iter(version\_lines), ‘’)  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 2627, in \_get\_metadata  
> May 10 12:35:23 pynq pl\_server.sh[3261]: for line in self.get\_metadata\_lines(name):  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 1408, in get\_metadata\_lines  
> May 10 12:35:23 pynq pl\_server.sh[3261]: return yield\_lines(self.get\_metadata(name))  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 1405, in get\_metadata  
> May 10 12:35:23 pynq pl\_server.sh[3261]: return value.decode(‘utf-8’) if six.PY3 else value  
> May 10 12:35:23 pynq pl\_server.sh[3261]: UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xd6 in position 9: invalid continuation byte  
> May 10 12:35:23 pynq pl\_server.sh[3261]: Error in sys.excepthook:  
> May 10 12:35:23 pynq pl\_server.sh[3261]: Traceback (most recent call last):  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/apport\_python\_hook.py”, line 63, in apport\_excepthook  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/apport/ **init**.py”, line 5, in   
> May 10 12:35:23 pynq pl\_server.sh[3261]: from apport.report import Report  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “”, line 971, in \_find\_and\_load  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “”, line 955, in \_find\_and\_load\_unlocked  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “”, line 665, in \_load\_unlocked  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “”, line 674, in exec\_module  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “”, line 779, in get\_code  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “”, line 487, in \_compile\_bytecode  
> May 10 12:35:23 pynq pl\_server.sh[3261]: ValueError: bad marshal data (invalid reference)  
> May 10 12:35:23 pynq pl\_server.sh[3261]: Original exception was:  
> May 10 12:35:23 pynq pl\_server.sh[3261]: Traceback (most recent call last):  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/local/bin/start\_pl\_server.py”, line 6, in   
> May 10 12:35:23 pynq pl\_server.sh[3261]: from pkg\_resources import load\_entry\_point  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 3088, in   
> May 10 12:35:23 pynq pl\_server.sh[3261]: @\_call\_aside  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 3072, in \_call\_aside  
> May 10 12:35:23 pynq pl\_server.sh[3261]: f(\*args, \*\*kwargs)  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 3101, in \_initialize\_master\_working\_set  
> May 10 12:35:23 pynq pl\_server.sh[3261]: working\_set = WorkingSet.\_build\_master()  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 565, in \_build\_master  
> May 10 12:35:23 pynq pl\_server.sh[3261]: ws = cls()  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 558, in **init**  
> May 10 12:35:23 pynq pl\_server.sh[3261]: self.add\_entry(entry)  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 614, in add\_entry  
> May 10 12:35:23 pynq pl\_server.sh[3261]: for dist in find\_distributions(entry, True):  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 1964, in find\_on\_path  
> May 10 12:35:23 pynq pl\_server.sh[3261]: for dist in factory(fullpath):  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 2034, in distributions\_from\_metadata  
> May 10 12:35:23 pynq pl\_server.sh[3261]: root, entry, metadata, precedence=DEVELOP\_DIST,  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 2473, in from\_location  
> May 10 12:35:23 pynq pl\_server.sh[3261]: py\_version=py\_version, platform=platform, \*\*kw  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 2835, in \_reload\_version  
> May 10 12:35:23 pynq pl\_server.sh[3261]: md\_version = \_version\_from\_file(self.\_get\_metadata(self.PKG\_INFO))  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 2437, in \_version\_from\_file  
> May 10 12:35:23 pynq pl\_server.sh[3261]: line = next(iter(version\_lines), ‘’)  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 2627, in \_get\_metadata  
> May 10 12:35:23 pynq pl\_server.sh[3261]: for line in self.get\_metadata\_lines(name):  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 1408, in get\_metadata\_lines  
> May 10 12:35:23 pynq pl\_server.sh[3261]: return yield\_lines(self.get\_metadata(name))  
> May 10 12:35:23 pynq pl\_server.sh[3261]: File “/usr/lib/python3/dist-packages/pkg\_resources/ **init**.py”, line 1405, in get\_metadata  
> May 10 12:35:23 pynq pl\_server.sh[3261]: return value.decode(‘utf-8’) if six.PY3 else value  
> May 10 12:35:23 pynq pl\_server.sh[3261]: UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xd6 in position 9: invalid continuation byte  
> May 10 12:35:23 pynq systemd[1]: pl\_server.service: Main process exited, code=exited, status=1/FAILURE  
> May 10 12:35:23 pynq systemd[1]: pl\_server.service: Failed with result ‘exit-code’.

Considering that it always worked can be a simple case of corrupted filesystem?  
Thanks  
Stefano

---

<div class="post-metadata">

**Author:** ![PeterOgden](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/peterogden/32/55_2.png) [@PeterOgden](https://discuss.pynq.io/u/PeterOgden)\
**Post date:** [May 10, 2021, 9:53am UTC](https://discuss.pynq.io/t/connection-refused-error-while-programming-zcu-104/2632/4 "2021-05-10T09:53:34Z")

</div>

Could be that a package that’s installed has a weird character in it’s metadata - [python - Can't run pip: UnicodeDecodeError - Stack Overflow](https://stackoverflow.com/questions/34440958/cant-run-pip-unicodedecodeerror) is very similar to the error you’re seeing.

Peter

---

<div class="post-metadata">

**Author:** ![stebosisio](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@stebosisio](https://discuss.pynq.io/u/stebosisio)\
**Post date:** [May 10, 2021, 4:59pm UTC](https://discuss.pynq.io/t/connection-refused-error-while-programming-zcu-104/2632/5 "2021-05-10T16:59:45Z")

</div>

At the end of the day the problem was effectively 99.99% due to a corrupted filesystem on the sdcard that, I can suggest also to others, I learned is the first thing to be checked when some strange behaviours starts to happen on this board. In my case lot of errors was listed by fsck and the same tool was not able to fix them at all. A fresh sd solved everything.
