Failed to bring up wlan0

I'm using Ubuntu Server, and this is what my /etc/network/interfaces looks like:

auto wlan0
iface wlan0 inet static
     address 192.168.1.68
     netmask 255.255.255.0
     gateway 192.168.1.254

and it gives me this error when I try to do sudo ifup wlan0

RTNETLINK answers: File exists
Failed to bring up wlan0

That message usually means that the route being added already exists.

  1. Run sudo ifdown wlan0 and sudo ifconfig wlan0 down (these will probably output errors, just continue).
  2. Then check the output of ip route for any routes related to wlan0. If there are any use sudo ip route del to remove them (for example, sudo ip route del 192.168.1.0/24 dev wlan0).
  3. Try sudo ifup wlan0 again.