Posts: 1
Joined: Thu May 09, 2019 9:40 am

ssh connection refused

Thu May 09, 2019 9:46 am

when i try to ssh connection from my android app to raspeberry using hostname "raspberrypi.local" and port is "2222" showing a error message connection refused but when i excute same code using a static local ip its working. How to fix it? please help me.

try {

SSHClient ssh;
Session session = null;

AndroidConfig config = new AndroidConfig();
ssh = new SSHClient(config);
ssh.addHostKeyVerifier(new PromiscuousVerifier());

//if (!ssh.isConnected())
ssh.connect("raspberrypi.local", 2222);
ssh.authPassword("pi", new PasswordFinder() {
public char[] reqPassword(Resource<?> resource) {
return "here i used my password".toCharArray();

public boolean shouldRetry(Resource<?> resource) {
return false;
session = ssh.startSession();
Log.e(TAG, "subscribe: is connected " + ssh.isConnected());
Session.Command cmd = session.exec(command);
} catch (Exception e) {

Posts: 9808
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: ssh connection refused

Thu May 09, 2019 3:28 pm

AFAIK there is no native support for zeroconf / mdns / bonjour / avahi on Android, so it does not recognise the .local name.
It's an Android problem, not Pi / Raspbian

Return to “Raspbian”