Here I present a list about places, you can spend a night for free when you travel. Of course it matters where you need that place, since noone would spend the night outside in Lapland, but in a warmer country it could be a solution too. Therefore now I just publish a raw list of places (and I'm waiting for more ideas in comment, I'm updating the post continously). If any time in the future you have no accomodation nor money in a foreign town, just open this list, and survive the night!
Airport
If there is an airport nearby, the floor of the departure hall could be used as an uncomfortable, but covered and safe bed.
Railway station
The advantage is, that it's available in most of the bigger towns and is mostly in the center. The disadvantage is, that it's either closed or already inhabited by people, you might won't trust even in the daytime. Sleep in a way, that noone can steal anything from you.
Bus station
Similar to the railway station, but less centrally located and rare to find it open during night. On the other hand it's really available in most of the towns.
Border
If you are close to the border, you can ask the guards to allow you to spend one night there. Be polite, let them work!
Waiting room
At the doctor or in a hospital, you can find plenty of empty seats during the night. If it's open, go in, but don't forget to ask permission first!
Bank
Some ATMs are located in a room open 24/7. Obviously it's full of CCTV, and the floor won't be too comfortable neither, but it could save your night too.
Embassy / consulate
Embassies and consulates are presented only in the biggest cities, and shall be used only in an emergency case.
Church
Or the praying building of any religion. Ask the person responsible for it, if you could spend your night inside! It's needless to stress out, but obviously act polite and with a big respect in such a place!
Prison
In case of commiting minor crimes, you won't automatically end up in a real prison, but in a cell at the police station. You can ask the local policemans, if they could take you there for a night without committing a crime.
Petrol Station
The advantage is that there are a lot of them, and if you are hitchhiking, there is a great chance you end up at one of them. Some of them are open during all night, here you can ask the staff if you could stay there. Try not to bother them with your presence, or even offer your help if needed!
Toilet
Sleeping at the public toilets isn't probably included to any of your bucket lists, but it's another way to survive the night. If it's open and even free to use, you can expect a condition, what might makes you change your mind pretty soon, and start to look for an other place....
Canal
Even more hardcore, than the toilet was, but let's include it to this list anyway.
Underground garage
Under big market halls, junctions and block of flats you might find a garage too. You can enter in the same entrance as the cars, then look for a relatively comfortable corner on the ground.
Shops
In those shops, open 0-24, you might ask the employees if you could stay there. Try not to bother them with your presence, or even offer your help if needed!
Homeless shelter
I don't know anyone, who tried this one, but in theory it could work - however raises some safety and ethical problems, and they might even ask for a little money.
Tourist Information
Ask the staff at the tourist information, where could you survive the night without money! If they don't know any place, ask about that exact building you are in!
Empty ruins, abandoned buildings
Not the safest and most comfortable place, but at least it's covered.
Under the bridge
Try not to bother the local homeless people!
Public park
In my opinion this is the most dangerous place, not recommended at all!
Forest
If there is a forest near and the weather is good too, why not? Some say, they worry about animals. I worry more about humans.
Camping
If you have a tent, why did you open this list at all? Search for a place far from others, set your tent and sleep! The same applies for those with a hammock.
Cave
Protects you from the rain, and has a relatively good temperature. This is where we humans started!
Truck
If you find a parking place for trucks, ask their drivers! They usually stay there for all night and have a vacant seat..
Alternative districts
In some bigger cities, you might find those kind of hippie districts, where anyone would gladly accomodate a poor traveller. You can easily recognize these places from the colorful graffitis, weed smell, surrealistic decorations, ruined buildings and green vegetation.
Changing room
The changing rooms at the beaches are usually left open, so if you can get there, they could mean a good wind protection for the night.
Sightseeing
If you are actually not that tired, and it's not that cold either, you can also stay awake. Do, what you would do during the daytime: see the town, swim in the sea, meet locals! On the next day you will anyway need a place to sleep soon, but it will be maybe easier to find, especially if you are taking a long train- or busride.
Hostel
Obviously hostels aren't free, but if you stay longer, you might make a deal with the owner of working instead of paying.
Pubs, Clubs
If there is free entrace and the place stays open all night, this could be also a possibility. When you arrive, look for a silent corner to sit! If you find some empty glasses take them to your table and pretend you are drunk! Put your head on the table and try to sleep! (Which won't be very easy in a noisy pub.)
Tunnel
In longer tunnels you can find several emergency exits. Behind these doors you can spend your night in a safe and warm place, but you need to be aware, that in most of these tunnels it is strictly forbidden to walk!
Boat
If you end up on the seaside, let's give a try to the local port too! Ask the captain or the owner of the boat, if you could spend the night on it!
Covered bus station
Protects you from the rain and wind, but won't be your most comfortable night.
Locals
There are plenty of websites and applications like couchsurfing, which can help you to spend your night at a friendly local. If you couldn't find any, don't worry! There are more friendly locals, who don't even know these sites! This is why it's very imporant in all cases to communicate with them: it happens often that seeing your problem, they offer their home for you. (For example the priest from the church, the young guys in the pub, the shop assistents from the stores and petrol stations or even the police.) You can ask random pedestrians as well, using the polish method gives you a very high chance to make it to a memorable night!