This is weird but I followed the steps to setup static IP using DHCP.

My dhcpcd.conf file:

interface wlan0
static ip_address=
static routers=
static domain_name_servers=

Rebooted and i could access google, search on it but a few websites are not able to open for some reason. For example, i could open facebook. But not github or stackexchange. No idea why. When wlan0 DHCP automatic, all websites able to open fine.

Anybody knows why and how to solve it?

EDIT: Thanks for responding to my question. So here is what I tried:

Based on answer shared https://raspberrypi.stackexchange.com/a/74428/133085 - using "request" in dhcpcd.conf, it resulted in Auto DHCP instead. that means my router is rejecting this IP for some reason.

The thing is, I COULD set a static IP address of (or any other number) on my Mac. So I know my router do accept static IP settings. Just on my rasp pi seems to be having this issue.

Also just to add the error I get from browser is:

This site can’t be reachedhttps://raspberrypi.stackexchange.com/ is unreachable.
  • What errors do you get? It is always worth using two DNS servers just in case one does not respond in time. developers.google.com/speed/public-dns Recommends AND for IPv4 though I normally mix DNS suppliers and use and if I'm ok with being tracked and get ads.
    – user130616
    Commented Apr 24, 2021 at 14:50

2 Answers 2


I found a workaround. The DHCP method doesn't work for me. I mean it did change the IP of rasp pi, and I am able to detect rasp pi on the wifi network using IP scanner, but.... the rasp pi itself fails to open some website (including this site). It can open google.com only.

So, what i did was added a ifconfig cmd line in the last line of .bashrc in /home/pi.

ifconfig wlan0

And it works. I still am interested if anybody got it working fully with DHCP method. So pls post your answer if there is one.


The most probable reason it works with DHCP in that this would be using the DNS provided by the ISP. Attempts to bypass this are not guaranteed to work as many jurisdictions require ISP to filter IP.

I suggest that rather than trying to set a static IP Address you request the DHCP server to assign a predictable IP Address. See https://raspberrypi.stackexchange.com/a/121830/8697

If for some reason you do want a static IP Address see How to set up Static IP Address which explains how to do it correctly.

  • Not working. I edited my question to add more details after following your advice.
    – GeneCode
    Commented Apr 25, 2021 at 4:15
  • @GeneCode The most likely reason for rejection is because is not within the range managed by the DHCP server . Only you can determine this by looking at your router settings. Many routers only allocate within a limited range. Routers DO NOT "accept static IP settings" - the router is NEVER consulted! If you want to involve the router you should use the inform directive.
    – Milliways
    Commented Apr 25, 2021 at 6:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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