16

I'm having a problem with my Raspberry Pi where I can't ssh into or even ping it, yet I'm using it on my TV, and it's clearly connected to the network/Internet.

I've used the attached keyboard to run several curl commands, wget, and apt-get update, and they all work fine, but I can't connect to it remotely using the IP address, and it won't respond to pings. I've just freshly installed Raspbian, and so far all I've done is set up Wi-Fi, which is clearly working.

  • Does your computer that you're sshing from have a firewall ? Have you double checked the IP address with /sbin/ifconfig just in case it's not the correct one ? – Lawrence Feb 6 '14 at 0:57
  • No, it actually worked fine right before i rebooted for the first time after I setup the wifi (I ssh-ed to make sure it worked, then rebooted, at which point it stopped working). I double checked the IP with "ifconfig wlan0" and found it to be the same as it has been. – Eric Wolf Feb 6 '14 at 1:01
  • update: I restarted it for the 20th time and it is now working... – Eric Wolf Feb 6 '14 at 1:10
  • plz paste your ifconfig – Alex Tape Feb 6 '14 at 9:16
  • 2
    This might be a power saving issue with your wifi dongle. Try to maintain it busy with eg ping google.com on the Pi and try ssh'ing at the same time. – M Noit Feb 6 '14 at 11:26
12

This happens a lot with one of my Raspberry Pis. I have a script which checks for an Internet connection and runs ifup wlan0 when a connection is not present. Some of the things you could try:

  • Rebooting the Raspberry Pi
  • Checking that you have a valid IP address using ifconfig
  • Ensuring that you have power-saving features disabled on the dongle by adding wireless-power off to your /etc/network/interfaces file
  • Run ifup --force wlan0

Here's a script which runs every five minutes from cron:

#!/bin/bash
#Script to check the network connection

#Check network connection
if /sbin/ifconfig wlan0 | grep -q "inet addr:" ; then
    #Connection is good; do nothing
    echo "$(date "+%D [%H:%M:%S]") Connection is up"
else
    echo "$(date "+%D [%H:%M:%S]") Network connection down. Attempting to reconnect..."
    sudo /sbin/ifup --force wlan0
fi

If that is a wireless card power management issue, you can also have a look at WLAN disappears after some time.

Many wireless network cards don't support wireless-power off option in /etc/network/interfaces. To disable power management with a 8192CU module loaded, you can create a file sudo nano /etc/modprobe.d/8192cu.conf with the following contents.

# Disable power management
options 8192cu rtw_power_mgnt=0
  • The internet connection is working and has a valid IP address, though I think your suggestion of adding "wireless-power off" has worked. If it doesn't fail in the next few days I'll accept your answer. – Eric Wolf Feb 9 '14 at 21:45
  • Did the fix work? I am facing the same problem. – zengr Apr 10 '14 at 23:22
  • @exantas: Can you share that script? I think I will need it too. – zengr Apr 10 '14 at 23:24
  • @zengr: edited my answer – nagyben Apr 10 '14 at 23:30
  • ah, the problem I am having is, I see inet addr: in ifconfig and I have a valid IP address but I am not able to ping/wget etc. – zengr Apr 10 '14 at 23:37
2

I have found myself in this issue before. Sometimes my router would pick up the wrong IP address. To fix the issue I used nmap to find my Raspberry Pi. I think that the command was nmap 192.168.1.0/24.

That should be able to find the IP address and help you to ssh and ping. If you are connected by a monitor then run ifconfig inside the terminal application.

2

I was having similar problems. With an Ethernet connection I could remote desktop from my PC into the Raspberry Pi, but with Wi-Fi the connection failed; I couldn't even ping the Raspberry Pi.

It turned out to be a router problem. I created a new rule for routing port 3389 (used by RDP) to the IP address of the Raspberry Pi (I also setup the router to assign the same IP address to the MAC address of the Raspberry Pi Wi-Fi). This resolved the problem. Ping still fails sometimes; I suspect that is more related to the power management solution mentioned above.

I found the instructions for my NetGear router setup in Port Forwarding the Netgear WGT624v3 Router for Remote Desktop.

1

try using raspi-config and enable ssh from interface option.

  • 1
    Will enabling SSH in the raspi-config fix the issue with ping? OP wrote: "I can't [ ] even ping it." – techraf Mar 15 '17 at 2:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.