I am running an Apache 2 web-server with MySQL and PHPMyAdmin but the 21, 22, and 80 ports act up all the time. The 21 and 22 ports stop working at about the same time but the port 80 works for a lot longer until it needs to be rebooted. But once on a blue moon, all of the ports will work for at least 1 hour until the 21 and 22 ports stop working. Oh and it is also connected to the internet via USB WiFi dongle. If you need anymore information I will be available.

Edits: I am running Raspbian Jessie Lite. I am using PuTTY and WinSCP to connect. I do not have an Ethernet cable to connect to the internet. My router is not port forwarded to 21 or 22.

I noticed a pattern in the errors. At first it tries to search for the Pi and fails. Next, it finds the Pi and gets refused. Lastly, it isn't refused and it starts working. It is not always like this but most of the time it is. It can stop working for days then suddenly work.

  • Does /var/log/syslog show anything at the times FTP (21) and SSH (22) stop working? Do you have a keyboard and monitor that you can use to see what the system is doing when the problem happens? Commented Feb 28, 2016 at 22:59
  • @HeatfanJohn It says invalid packet response from But the computer that I am trying to connect from is And yes I do have a keyboard and monitor that I use for the Pi but nothing special happens. Commented Feb 28, 2016 at 23:18
  • How is the Pi connected to the network? Commented Feb 29, 2016 at 6:00
  • @SteveRobillard The post says via WiFi dongle. Commented Feb 29, 2016 at 6:01
  • Are you sure the WiFi is not dropping out? How is the dongle powered? Can you reproduce the problem when using ethernet? Commented Feb 29, 2016 at 6:13

3 Answers 3


Sometimes people try to hack into your computer from the internet. People (even foreign governments) scan every ip address looking for computers listening on known ports such as 21, 22, and 80. From my experience, it takes about ten minutes on the internet before somebody starts to try to hack into your pi. They try to log in with many different common passwords and sometimes crash the service. I recommend changing ports 21 and 22 to something else.

Edit the /etc/ssh/sshd_config file, and change the line with 'Port 22' to 'Port 2022' (or add that line if it's not there) While you're there, make sure that 'PermitRootLogin' is set to 'no' reload the sshd config (/etc/init.d/ssh reload), and you should be able to log in on port 2022 from now on.

Changing the ports to different numbers means someone would have to do a port scan to find the open ports. Configure your router to block and detect port scans. But I dont know how to turn off the government back door in your router.

I don't have instructions on how to change port 21 because I use ftp over ssh.

  • OP says "My router is not port forwarded to 21 or 22." so this is no issue here.
    – Havnar
    Commented Mar 2, 2016 at 12:27

I had some similar issues, which can be lumped together as "flakey behavior".

My problem was the power source. I was using the USB port on another device, that couldn't consistently deliver enough current to the Pi. E.g. when the disks in that device were seeking. New 2 amp power supply, and my problem was solved.

  • It is connected via an adapter so that can't be the problem. Commented Apr 23, 2016 at 19:35

Your problem may be that there are other things on the pi using these ports:

  • Port 21: FTP control;
  • Port 22: SSH, secure logins, port forwarding and others;
  • Port 80: HTTP;
  • So how do I fix it. Commented Aug 12, 2016 at 22:16
  • Try checking the rest of your pi and delete any programs that may be using these ports. To uninstall: sudo apt-get purge program-name
    – Oliver
    Commented Sep 25, 2016 at 16:11
  • There is nothing forwarding to 21 and 22, and the only thing I have forwarded if my raspberry pi port 80. Commented Sep 26, 2016 at 22:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.