DHCP failure on Android WiFi (stuck on obtaining IP address) – How I solved it

This evening my phone wouldn’t connect to my WiFi network anymore after a SIM change + reboot (maybe unrelated?).

Anyway, it seems that many people are affected by this issue, but it took me a while to find a workaround, because I found a lot of incomplete and fragmented information. I’ll try to put everything in this post so people with the same problem can hopefully spend less time to solve it.

My configuration: Sony Ericsson Live with Cyanogen mod 9 (Android 4.0.4).

Problem description

Wireless card will not connect to WiFi network when using DHCP (in my case the AP is a CISCO router flashed with DD-WRT and secured with WPA2). In the Android WiFi settings, you will see the connection status looping between the same states over and over (the most noticeable is “obtaining an IP address” as that string remains on the screen longer).

To investigate a bit on the cause of the issue, I had a look at the ERROR logs, that revealed the failure of DHCP:

E/DhcpStateMachine( 218): DHCP failed on wlan0: DHCP result was failed
E/WifiStateMachine( 218): IP configuration failed
E/LanLinkProvider( 471): Sending udp identity package failed
E/LanLinkProvider( 471): Sending udp identity package failed
E/LanLinkProvider( 471): Sending udp identity package failed
E/LanLinkProvider( 471): Sending udp identity package failed
E/DhcpStateMachine( 218): DHCP failed on wlan0: DHCP result was failed
E/WifiStateMachine( 218): IP configuration failed
E/LanLinkProvider( 471): Sending udp identity package failed
E/LanLinkProvider( 471): Sending udp identity package failed
E/DhcpStateMachine( 218): DHCP failed on wlan0: DHCP result was failed
E/WifiStateMachine( 218): IP configuration failed
E/LanLinkProvider( 471): Sending udp identity package failed
E/LanLinkProvider( 471): Sending udp identity package failed
E/DhcpStateMachine( 218): DHCP failed on wlan0: DHCP result was failed
E/WifiStateMachine( 218): IP configuration failed
E/LanLinkProvider( 471): Sending udp identity package failed
E/LanLinkProvider( 471): Sending udp identity package failed

Solution

What worked for me (and hopefully for someone else too), was to delete every files in

/data/misc/dhcp

In my case, I had the following two files:

dhcpcd-wlan0.lease
dhcpcd-wlan0.pid

So, if you can access the adb shell, you can try the following (please, see which files you have there with “ls”, so you will correctly remove what you need):

$ adb shell
# cd /data/misc/dhcp
# rm dhcpcd-wlan0.lease dhcpcd-wlan0.pid

Or, if you cannot use the adb shell, try to remove those files with a file explorer directly from the device.

After this, I had to reboot before I could get my WiFi connection work properly with DHCP.

Credits go to this page: http://forum.xda-developers.com/showthread.php?t=2112161.

Advertisements

37 thoughts on “DHCP failure on Android WiFi (stuck on obtaining IP address) – How I solved it

  1. You’re a genious! It worked for me…thanks! And if your phone is rooted you don’t even need adb. Just install terminal emulator (and bash X if you want)

      1. The fact that they just come back might not be a problem, but I imagine that your problem is not fixed, right? I don’t have this anymore on my phone, so I cannot reproduce your case…

  2. Hello i need your help with this. Do ypu need to be rooted to do this cuz whenever i use static ip and it seems to connect but it will only allow me to connect to https sites. Please help

    1. Yes, you need to be root.
      But if you can connect to at least some sites, that means that you are definitely already connected to your access point, so the problem described in this post doesn’t affect you.

  3. I have already removed the .pid (which was what is only my dhcp folder) then rebooted and still with the same issue, tried factory resetting still no luck with it.

    1. One thing that helps me is to delete the files while the wireless is disabled, then enable it again (no reboot is needed in my case, I can usually connect afterwards).

      1. Sad to say still that didn’t work but I can now connect after I restored my router to factory settings and connecting there even before I add security to it.,

  4. i have done exactly what you said 😦 ive searched heaven and hell for a solution my phone is still stuck on obtaining ip address, i went to root browser through romtoolbox lite and deleted every file in dhcp, rebooted my phone but the problem still persists, yesterday i had another problem my phone would connect perfectly to a wifi connection but it wouldn’t access internet, so earlier today i changed the ip etc, and now its getting stuck at obtaining ip.

    1. You should check the logs to determine whether your problem is exactly the same that is described in this post. Anyway, one thing that sometimes help me is to disable Wi-Fi, then delete the files, then enable Wi-Fi again.

  5. same problem here i have tried all the above solution like deleting dhcp files and restarting the phone but still the issue persists….please suggest me what to do now?

  6. Hi, I cannot find the following directory on my Asus ME173X tablet:
    /data/misc/dhcp

    I also tried searching directly for the files:
    dhcpcd-wlan0.lease
    dhcpcd-wlan0.pid

    But cannot find those either. Any ideas on where I can find them so I can delete them?

    Thanks,
    Marco

      1. If

        find / -name dhcpcd-wlan0.pid

        didn’t give you anything, then you probably have a different issue, or an android version for which this solution cannot be applied :(.

  7. um sorry how do i delete the /data/misc/dhcp file??? i have no idea where is it located, i can’t find it in Files folder?? please help

  8. If you can’t root your phone and it’s not working, it is very useful to do what i did: i changed the setting of my router and added a dhcp reservation for my phone. For that you will need to access your router settings (instructions on the router). I chose a reserved ip (in my case 192.168.0.69) and changed my phone´s setting to ip static with that ip. Then at least i could connect to wifi home.

  9. Hi guys, I’ve been having this issue for a long time now, and at some point after trying fixing apps without any success (and I didn’t want to root my phone) I decided to erase my phone and start again. Now it’s working perfectly fine and most of my settings were backed up anyway: I’ve been trying to fix it for weeks and erasing it and resetting it up took me a morning.

  10. I’ve tried your sollution but it didn’t work for me…
    I flashed TWRP on my SM-J320FN and deletet all files in data/misc/dhcp/ , but there was only dhcpcd-wlan0.pid dat, no dhcpcd-wlan0.lease
    After rebooting several times and deleting the .pid dat every time for new it even didn’t helped.
    At the moment I’m using a static IP, but thats no final sollution for me…
    Sorry for my bad english,
    Bueld

  11. I ran into the same problem in CyanogenOS (version 13) on Wileyfox Spark +. It kept hanging at “Obtaining IP address”.
    In “Developer options” I selected “Use legacy DHCP client”. This made all work again with the Cisco network at work.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s