I have a Raspberry Pi 3. On my Raspberry Pi I have a Python script that initializes a Flask server, the Python script returns some basic JSON. The Python script is initiated on boot using process manager PM2. The python script is then accessible by the IP address so it can be accessed by other devices. It's basically a small Python API.

This setup works fine but eventually stops working with no indication as to why. When I use my terminal to try and find the cause everything seems to be running fine. PM2 started properly. The IP address of the Raspberry Pi resolves. But my address to the Python Script does not. The address is something like this:

The JSON response (which was working) gets replaced with an error page "This site cannot be reached, refused to connect".

Any adea as to what might be causing this? Or what I could do do find the problem?

If I re-image the SD card with the original working image everything works again, until it unexplainably stops again.

On a side note...

The Raspberry Pi is connected to a BrickPi. The BrickPi is basically an adapter that allows the Raspberry Pi to connect to LEGO EV3 sensors and motors. More data is available here:


I think the BrickPi is unrelated to the issue I'm having.

  • "refused to connect" means that there is no process listening at the target port, that usually means the server process didn't start or encountered an error. – RalfFriedl Apr 16 at 5:07
  • What is PM2? Why does your python script have an ip address? Please address me with @Ingo, otherwise I won't see your reply. – Ingo Apr 16 at 8:36
  • @Ingo PM2 is a process manager - pm2.keymetrics.io – Adam Thomas Apr 16 at 18:02
  • @RalfFriedl Thanks. I'll look into that. PM2 says it's running, but I'll try starting it manually and see if that resolves the error. – Adam Thomas Apr 16 at 18:04
  • Thanks. I have updated your question. You should better edit your question by yourself instead of giving infos at comment :-) But again: why does your python script have an ip address? – Ingo Apr 16 at 18:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.