Q: I am looking for 1 night accommodation within walking distance to the airport, say 3 km.
A: There are a number of hotels close to Barcelona airport. I have given link to hotel within 3KM of Barcelona Airport below. You can reserve your hotel online.
Best Western Alfa Aeropuerto Hotel only 2 KM from the airport. This is one of the nearest hotels to the Airport.