first of all let me say I'm a beginner so assume I don't know anything. Okay, now my problem. I'm trying to set up my old PI2 to be a terraria server to play with some friends. Everything was working fine but at some point my pi2 stopped being connected to internet (i'm using an ethernet). I've looked online but none of the things i've done worked. Any suggestions? I think it may be related to some DHCP problems but as I said i'm a beginner and I don't even know what DHCP is. Thanks for the help.

PS: among the things that I tryied i guess this one was the only one worth telling:

sudo nano /etc/dhcpcd.conf


interface eth0
static ip_adress=
static routers=
static domain_name_servers=

where "" is my router's adress

Sorry again if I made some stupid mistakes/assumpions but i'm a beginner and I know very little.

EDIT: This is the output log of some commands I've been suggested to try:

pi@raspberrypi:~ $ sudo ping
connect: Network is unreachable
pi@raspberrypi:~ $ sudo ping
connect: Network is unreachable
pi@raspberrypi:~ $ sudo ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether b8:27:eb:26:9a:72  txqueuelen 1000  (Ethernet)
        RX packets 320  bytes 15316 (14.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 30  bytes 4784 (4.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet  netmask
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

pi@raspberrypi:~ $ sudo ip -4 addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    inet scope host lo
       valid_lft forever preferred_lft forever
pi@raspberrypi:~ $ sudo ip -4 route show
pi@raspberrypi:~ $ sudo cat /etc/resolv.conf
nameserver $ 
  • Hello and welcome -- "Everything was working fine but at some point my pi2 stopped being connected to internet', how you deduced that the internet is not accessible for the raspberry pi? -- Try ping to find out are the pi connected to router or not. Then, ping to check google dns servers is accessible. The output should not be the request time out ... or host unreachable ... – M. Rostami Feb 3 '20 at 17:31
  • 1
    In this case, there is a lot of possibilities. It would be helpful to add the output of these commands to the question body. -- ifconfig | ip -4 addr show | ip -4 route show | cat /etc/resolv.conf – M. Rostami Feb 3 '20 at 17:35
  • I'll try to explain better, sorry. Basically as soon as I started it my pi2 wasn't connected to the internet (i'm running some kind of gui and it just says "disconnected"). But in an afternoon of trying, out of nowhere it started to work. So I just went on with my business. Then, the pi2 froze and I had to reboot and then the internet connection was gone again. Just to be sure, the ethernet cable works just fine (writing this from my desktop with the same ethernet) I've done all of the things you asked me to and here's the log. I'll put it in the body too. Thank you for your help. – Nicola Feb 3 '20 at 19:22
  • 1
    Setting a static IP address is not necessary, and if wrong causes problems. Delete all the stuff you put in dhcpcd.conf and let the network do its job. If you still have problems describe the status lights on the Ethernet interface. – Milliways Feb 3 '20 at 23:57
  • @M.Rostami DO NOT advise people to run deprecated commands - tell them how to do it properly. – Milliways Feb 4 '20 at 0:01

Already the first command ping with "Network is unreachable" shows that your connection to your router is broken. It seems that there is no ethernet cable connected to the router (I know there is). I don't know what you already have tried but the first step would be to check the ethernet cable. Maybe it's broken or has a bad connection. Try another cable. It's also possible that your router is down. Reboot it. It is important for the first step that ping gives you a reply, something similar to this:

pi@raspberrypi:~ $ ping
PING ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=64 time=1.39 ms
64 bytes from icmp_seq=2 ttl=64 time=1.68 ms
64 bytes from icmp_seq=3 ttl=64 time=2.38 ms

--- ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 6ms
rtt min/avg/max/mdev = 1.388/1.813/2.375/0.414 ms

There may be another issue with your ip address. You have given your RasPi a static ip address, routers and domain_name_servers in /etc/dhcpcd.conf. It may be possible that this conflicts with another device on the network having the same ip address Ip adresses are usually managed by a DHCP server mostly running on the router. It depends on how the router manages such conflicts. I know router that will disconnect the conflicting line (your ethernet cable). Try to just comment the three static entries in /etc/dhcpcd.conf and reboot the RasPi. Then it should get a valid ip address from the router/DHCP server and other needed options.

  • The ethernet cable works just fine, and I'm 100% sure about that. I'm using it right now to surf on my desktop. I understand that the problem is that at the moment it looks like the ethernet isn't working but that's what I'm trying figure out! Any other ideas? Thanks for your help! – Nicola Feb 3 '20 at 20:02
  • @Nicola I have updated the answer. – Ingo Feb 3 '20 at 20:06

Comment or remove these lines of /etc/dhcpcd.conf:

interface eth0
static ip_adress=
static routers=
static domain_name_servers=

If the router does its job (DHCP server is enabled), the raspberry pi would get an IP address from the router. Therefore, after removing these four lines, try to check that is router reachable for raspberry pi or not:

ping -c 3 

By this command, you'll send three ICMP packet to the router and if it's reachable it will say you (on statistics part of output) 3 packets transmitted. If it's not worked and says request time out ... or host unreachable ..., you should troubleshoot this situation.
At first, try to realize that is there any DHCP server enabled on the router which you have connected raspberry pi to:

ifconfig eth0

And the output should be something like this:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet  netmask  broadcast
        inet6 fe80::fe99:6c74:e7bd:1883  prefixlen 64  scopeid 0x20<link>
        ether b8:27:eb:2a:8f:d5  txqueuelen 1000  (Ethernet)
        RX packets 1660  bytes 109201 (106.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 345  bytes 45728 (44.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0  

Look at the inet netmask section. It means that the raspberry pi gets an IP address which is Next, you need to find gateway's IP address which is the IP address of the router:

route -n

It will give you the gateway's IP address which can be something between to and of course it's not After that, like previous procedures, ping that address to ensure the connectivity.

NOTE: If you couldn't find any IP address when you run ifconfig eth0, it's not the raspberry pi's fault. You need to check out your local network configuration to find the problem.

If all the procedures above would be successful in your case, you can try the internet connectivity by pinging or www.google.com.

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.