Support Questions
Find answers, ask questions, and share your expertise

Issue using scp on HDP 2.4: "ssh: connect to host localhost port 2222: Connection refused"

I am trying to setup nifi on HDP 2.4 (Oracle Virtual Box on Windows 10) for the sentiment analysis tutorial, but when I try to transfer the HortonWorks DataFlow file to the virtual machine with the command:

scp -P 2222 ~/Downloads/HDF- root@localhost:/root

I get the error:

ssh: connect to host localhost port 2222: Connection refused
lost connection

I added port forwarding for ssh in Virtual Box with Protocol=TCP, Host IP =, Host Port = 2222, and Guest Port=22. Also, I was able to successfully log in to Ambari and everything seems to be working. Furthermore, I added Virtual Box to my Firewall exceptions in case it was being blocked and am using the NAT network mode. I'm at a loss at this point. Any ideas as to why I can't connect using ssh?


You are trying to do ssh on same server or from outside?

New Contributor

I am having the same issue..has there been any resolution?

New Contributor

can you try disabling your windows firewall?

Super Guru

Can you restart network service of your HDP VM?

service network restart

I have faced similar issue for Sandbox multiple times and I could resolve it by restarting network service.

New Contributor

Hi, was this issue ever resolved? If s could you please share resolution if you don't mind?

I'm having the exact same issue and not sure how to proceed at this point.

New Contributor

@Sergei What is the status of sshd service? Could you try restarting sshd service by command service sshd restart ?

Does anyone get to the solution of the issue till date? plz share..

New Contributor


I think the solution should follow this action plan:

  1. install iptables e.g. this way
  2. then you need to open the 2222 port
  3. send the file over ( in my case )
 scp /home/pchpc/vms/file root@

This has worked for me.

Hope this helps


Try to connect to vm with vm ip.

ssh -P 2222 someFiles root@