Page 1 of 1

ssh connection refused

Posted: Thu May 09, 2019 9:46 am
by debdeep
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) {

Re: ssh connection refused

Posted: Thu May 09, 2019 3:28 pm
by DirkS
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