there are many things you can do:
1) check at the local hostals and hotels
2) go to the ayuntamiento and ask them what to do. When the albergue is full they sometimes open up the sports hall, medical clinic, schoolhouse, jail, or garage for pilgrims´use.
3) go to the parish office. Sometimes they know of places you can sleep.
4) Ask a policeman.
5) Ask a bartender.
6) Ask the old folks sitting on the bench in the plaza.
7) Sleep on the church porch.
8)Sleep under the bridge.
9)Sleep in a haystack, or out in a field under the stars.
10) Keep going to the next village and try your luck there.
11) Hire a cab and ask him to take you to a place to sleep.
Some of these may get you a place to sleep on the floor. You may not be comfortable, but you´ll likely be out of the weather. I slept in a haystack one night, and a jail cell another time. Somehow I did not die. And it gave me stories to tell later!