If you are experiencing the same error, you should look for this article’s guidelines, where we will show you the major causes for this problem to occur and you can fix them to establish a successful SSH connection on Raspberry Pi.
Fix Connection Refused By Port 22 on Raspberry Pi
There are several reasons that refuse the Raspberry Pi’s SSH connection on Port 22 and the details of these reasons with their fixes are provided below:
1: Ensure SSH is Enabled
Sometimes users forget to enable SSH service on their Raspberry Pi devices, resulting in a connection refused error by port 22. You should enable the SSH service on your device first if you want to access your device remotely. You can enable this service easily from the Raspberry Pi desktop main menu in the “Raspberry Pi Configuration” option.
2: Slow Internet Connection
A slow internet connection is a significant problem that prevents your SSH connection from operating on Port 22. This will also prevent Raspberry Pi users from remotely accessing the device. Make sure that your internet is working fine because if there is any problem with your connection, you must fix it and then try accessing your device through SSH again.
3: Wrong Raspberry Pi IP Address
Ensure that the IP address you are providing is the exact IP address of your Raspberry Pi device. You can confirm the address by opening the terminal and applying “hostname -I” to get the IP address of your Raspberry Pi device.
4: Wrong Port
If your internet is working fine and your address is correct, you should check whether the port number you are providing is 22. The reason is the Raspberry Pi’s SSH connection operates on port 22 by default.
5: Ensure Username is Correct
The username is used when accessing the Raspberry Pi terminal from the Command Prompt or PuTTY. In that case, you may experience the access denied error due to adding an incorrect username or password. You must be careful in knowing your username and password. If somehow you forgot your username, you can find it by opening the Raspberry Pi terminal.
For password recovery, you can apply the following command to change the password for your Raspberry Pi:
I hope that the above fixes will help restore your SSH connection on your Raspberry Pi device.
Conclusion
Connection Refused by Port 22 error is annoying for most users since it permits them to access the Raspberry Pi remotely. You will find some fixes in the guidelines mentioned above that will help them fix your SSH connection. Later, they can establish a successful connection to access your Raspberry Pi terminal or desktop from a remote location.