I am a beginner in hacking. I have been trying to hack Windows XP using the netapi exploit in metasploit, but every time, in the end, I get an error:

Exploit failed [unreachable]: Rex::ConnectionRefused The connection was refused

Exploit completed but no session was created. 

I even tried turning off the firewall and tried to ping my XP machine with kali and it was doing it well. Can someone help me with this problem?

  • This is most likely a networking issue. Start a network troubleshooting process.
    – schroeder
    Jul 3, 2021 at 15:54

1 Answer 1


Check that the remote port has been set correctly before running the exploit.

In Metasploit, run the “options” command and look for the RPORT value.

Also check that the netapi service is actually listening on the network interface you are directing the attack at. You can use the “netstat” command in Windows for this.

  • The RHOST has been set correctly and RPORT is default set (445 I guess) but still it says me session not created. Jul 4, 2021 at 18:24

Not the answer you're looking for? Browse other questions tagged .