I'm trying to run my Raspberry Pi 4 on Ubuntu Server 20.04 (64bit) following this tutorial. When I reached 4. Boot Ubuntu Server, my RPi had no IP address (I switched to using a monitor when doing a headless setup failed, and calling hostname -I returns a blank line), which I believe is the result of having no internet connection, further demonstrated by sudo apt update failing with every line saying temporary failure resolving 'ports.ubuntu.com'. I also get a blank line when calling arp -a | findstr b8-27-eb from the Windows command prompt.

The tutorial had me modify the network-config file before inserting the card into the RPi which I did, and through some exploring, this had the following effect on /etc/netplan/50-cloud-init.yaml (with WIFI-NAME and WIFI-PASSWORD being what they should be):

# this file generated from information provided by the datasource. Changes
# to it will not persist across an instance reboot. To disable cloud-init’s
# network configuration capabilities, write a file 
# /etc/cloud/cloud.cfg.d/99-disable-network-config-cfg with the following:
# network:{config: disabled}
            dhcp4: true
            optional: true
    version: 2
                    password: WIFI-PASSWORD
            dhcp4: true
            optional: true

In spite of this, my RPi 4 is still unable to connect to WiFi. If it's relevant, the first time I booted the RPi I didn't actually get the IP address since I disliked the angle of the cord so I unplugged it after a minute or two, plugged it back in, and on the second boot was when I attempted to get the IP.

What am I doing wrong? Or is the issue perhaps with Ubuntu 20.04 and I should use Ubuntu 18.04.4 until 20.04 stabilizes?

  • You listed a tutorial, but have NOT followed it! NOTE the arp instructions are WRONG for a Pi4, but there are better methods of determining IP. How do you know "my RPi 4 is still unable to connect to WiFi"?
    – Milliways
    Commented Apr 25, 2020 at 6:53
  • @Milliways I've updated my post to better reflect the steps I did.
    – Drake P
    Commented Apr 25, 2020 at 9:17
  • I am having this exact same issue. sudo iwlist wlan0 scan is even picking up the network I want to connect to, but the system dialog for Wifi says that I don't have a wifi adapter installed. Commented Apr 25, 2020 at 22:49

5 Answers 5


I've had similar adventures over the last few days :) My system is now:

  • burn image of ubuntu server 20.04 onto sd card
  • boot rpi
  • write network: {config: disabled} to /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
  • write the following to /etc/netplan/01-netcfg.yaml:
  version: 2
  renderer: networkd
      dhcp4: true
      dhcp6: true
      optional: true
          password: "**********"
  • then do:
sudo netplan generate
sudo netplan apply

wifi now works for me, and then you can do stuff like apt update and install a desktop and stuff

For more info on netplan, check out https://netplan.io/examples

  • 2
    I am going to try this tomorrow, because I am in the exact same situation. Could you explain what the network: {config: disabled} line does? In addition, when I run sudo netplan apply, I get Warning: The unit file, source configuration file or drop-ins of netplan-wpa-wlan0.service changed on disk. Run 'systemctl daemon-reload' to reload units. Commented Apr 27, 2020 at 6:19
  • the config: disabled part turns off the "cloud config" networking stuff that's configurable in the 50-something file in cloud.cfg.d. I've had a couple of occasions where I encountered warnings when running apply too, but after reboot, it always works :)
    – Andbdrew
    Commented Apr 30, 2020 at 21:59
  • Thank you for this great answer. I owe you a beer :)
    – ndreisg
    Commented May 27, 2020 at 17:25
  • Is there any way to do this without connecting a keyboard and monitor to the Pi? I'm trying to manually tamper with them as little as possible so that they are easily re-imagable... thanks! Commented May 29, 2020 at 20:38
  • As of Jun3 15,2020, slight update. I also got the Run 'systemctl daemon-reload'. Tried it. It exited with non-zero error, I think it was 5. I tried the reboot. No good. No wifi. Repeated the process. Same. No good. Then I did a full shutdown and poweroff instead of reboot. Powered back up and after giving the login prompt, it also then gave some status and versions info for several lines, where I was supposed type in the login user. I went ahead with user and password, as if those messages had not stomped on the login area and had not repositioned the cursor. Successfully loggen in. Commented Jun 15, 2020 at 19:18

Using Andbdrew's tips above I was able to make this work headless (and with a head) consistently without disabling Cloud-Init. Thanks to @enconn, for brainstorming and a link to https://cloudinit.readthedocs.io/en/latest/topics/examples.html#reboot-poweroff-when-finished.

  1. Image the SD Card using Raspberry Pi Imager v 1.3 selecting the 'UNBUNTU 20.04 LTS (RASBERRY PI 3/4)(64-bit) image.
  2. When imaging is completed, remove the SD Card and then reinsert it so that it is mounted.
  3. Modify 'network-config' found on the SD Card so that it contains only the items in the example below. Comment out with #, or remove, all other settings including the LAN ones. Enter any missing items. Be certain to maintain only the indentations shown. Use two spaces for each indentation. Remove all tab characters. Be especially careful if using Notepad++ as it will enter tabs wherever enter is used to start a new line. Replace the SSID with your wireless SSID and the PassPhrase with your wireless passphrase. When done, those two values should be wrapped in quotes. Save the modified file to the SD Card.
  4. Edit 'user-data' appending the additional lines shown below. Again, use spaces, not tabs and mind the indentation.
  5. Eject the SD Card, remove it from the computer used to image it, and then insert into the powered off Raspberry Pi. Then, power up the RPi.
  6. Allow Ubuntu to boot; DO NOT try to log into Ubuntu as soon as possible. Wait until Cloud-Init runs (although it appears to be doing nothing - in about two minutes it will show SSH info when done). If you don't wait you may not be able to logon with the default user and passwd. At the end of the cloud-init,Ubuntu will be rebooted. What a couple of minutes for the server to boot.
  7. Logon either at the console or remotely using ssh [email protected] (get the address from your router, etc.)

That's it: Headless, Wi-Fi'd Ubuntu 20.04 on Raspbery Pi 4b

network-config example:

# This file contains a netplan-compatible configuration which cloud-init
# will apply on first-boot. Please refer to the cloud-init documentation and
# the netplan reference for full details:
# https://cloudinit.readthedocs.io/
# https://netplan.io/reference

version: 2
renderer: networkd
    dhcp4: true
    dhcp6: true
    optional: true
         password: "PassPhrase"

Append this to the end of 'user-data':

##Reboot after cloud-init completes
  mode: reboot
  • 1
    This works perfectly as a one-step solution, without needing to log in and perform other actions
    – Crollster
    Commented Jul 1, 2020 at 0:39
  • The reboot is the critical part here. Though, why doesn't it pick up WiFi settings on initial run? That prevents package_update & package_upgrade runs from finishing successfully. Commented Jul 6, 2020 at 18:28
  • You are a hero.
    – Rijumone
    Commented Aug 16, 2020 at 9:54
  • Correct answer - helped me for headless setup of ubuntu 20.04.2 on my rpi4. Thanks. Commented Mar 16, 2021 at 5:26
  • after trying for hours to figure out why I couldn't get a headless install working - I attempted to do a semi manual install. the reboot was key. This answer helps! PI is now working as intended thanks!
    – Umar.H
    Commented Jul 5, 2021 at 16:29

Issue is because of this bug https://bugs.launchpad.net/ubuntu/+source/netplan.io/+bug/1874377

Currently Ubuntu 20.04.1 needs reboot even though the issue is supposed to be fixed. Cable internet connects immediately. Ubuntu 20.10 connects to wifi even without reboot for now.



This script named first_run.sh asks you for your wifi ssid and wifi password and automatically connects your Raspberry Pi 4 to your wifi:


# Verify internet access is available
while [ $(ping -q -w1 -c1 google.com &>/dev/null && echo online || echo offline) == offline ]

    sleep 1
    # get wifi module
    module=$(ls /sys/class/net)
    echo $wlan_module

    # get wifi configuration file
    config_filename=$(ls /etc/netplan)
    echo $config_filename
    # check if the wifi is already added.
    if ! grep -q "$wlan_module" "$config_filepath"; then
        echo "have to add wifi"

        # ask  wifi pwd ssid
        read -p "What is the wifi ssid you want to connect to(Case sensitive)?" ssid

        # ask wifi pwd
        read -p "What is the wifi pwd?" pwd

        # append content
        echo "    wifis:" | sudo tee -a $config_filepath 
        echo "        wlan0:" | sudo tee -a $config_filepath
        echo "            dhcp4: true" | sudo tee -a $config_filepath
        echo "            optional: true" | sudo tee -a $config_filepath
        echo "            access-points:" | sudo tee -a $config_filepath
        echo "                \"$ssid\":" | sudo tee -a $config_filepath
        echo "                    password: \"$pwd\"" | sudo tee -a $config_filepath

        # generate a config file
        sudo netplan generate

        # apply the config file
        sudo netplan apply

The script is verified on a new Ubuntu Server 20.04.2 LTS 32-bit server OS for armhf architectures on the RaspberryPi with 4gb ram that was written to an sd card using the Raspberry Pi Imager.


You can copy first_run.sh to a usb stick, then plug it into your Raspberry Pi 4 and run it with:

sudo mount /dev/sda1 /media/
sudo chmod +x /media/first_run.sh

It will loop until the internet connection is established.


I used your method but on a different file. sudoedit /etc/netplan/50-cloud-init.yaml

you don't have to do the sudo netplan generate or reboot. It will work straight away after the sudo netplan apply

  • I believe this would only be a temporary solution, since 50-cloud-init.yaml says Changes to it will not persist across an instance reboot.
    – Drake P
    Commented May 11, 2020 at 14:49
  • @DrakeP I wonder why raspberrypi.stackexchange.com/questions/98598/… is suggesting to update that very same file. This is confusing.
    – piepi
    Commented Jul 28, 2020 at 11:19

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