You can't. By accepting a potential project, you take a risk to fail to negotiate it. The only way to avoid failed negotiations is to not negotiate at all.
That's also part of your job as a freelancer: you have to deal with the customers who may cancel their project before this project is started, or go to another freelancer who does the work better or at lower cost.
This being said, you can reduce costs spent to evaluate the price of a service.
1. Request the preferred and the maximum cost
One of the ways is to actually ask your customer how much he pay you. It helps a lot in some cases, depending on your customers by eliminating the projects where the customer cannot pay the real price.
For example, working in France, I often see the customers who are willing to pay no more than $500 for a large e-commerce website, and they just can't imagine that they must at least add a zero at the end.
In this case, I don't spend time doing evaluation (which itself can cost up to $200), but kindly explain to this person that their funding is too low, and that they may either want to raise it, or search for alternative solutions like already built solutions.
It also helps in cases where there is a doubt. For example I use it a lot when doing evaluations of cost of a change of an existent project. Sometimes, I can't say precisely if it will cost $100 or $1 000 or whatsoever (imagine a large codebase with legacy code no one can understand, and a bunch of unclear requirements).
If the customer tells from the beginning that he is willing to pay $400 and he can't pay more than $750, I start the evaluation, and stop it as quick as I can determine that the cost will be higher than $750. In fact, the waste of time and resources can be strongly decreased, since you usually get a large min-max range, then make it more and more precise. Taken the previous example, after an hour, I would be able to find that the price will vary from $600 to $1 800. After two hours, I'll find that it's between $800 and $1 300. At this moment, I can stop, since the lowest price is higher than the maximum amount the customer can pay.
2. Give to your customers as much information as you can about the prices
It's easy for us to know that an e-commerce website written from scratch cannot cost $100. But the customers have no idea about the prices most of the time. They don't know what is the amount of work required to do their project. They don't know how much to pay to a developer per day.
By providing precise information about your costs, including the rate per hour, the examples of the previous projects with their price, you will see less requests from people who are willing to spend an extremely low amount of money. If you don't provide any of this information on your website, the only way for them to know the price is to submit you a project and ask for a price.
3. Project triangle: price ↔ speed ↔ quality
To address your comment, consider the last point. Customers are usually interested by two points: how quick the project will be finished and how much it will cost. Strangely, they forget the most important point: the quality.
It forces some developers to lower the cost by lowering the quality. After all, if customer care as much about the cost, why would we bother providing quality?
Instead, you may provide an alternative approach when dealing with your customers. If they request a website which reasonably costs $6 000, and they tell you that they can pay $20 000,
- From the beginning, tell them from the beginning that the project will cost much less,
- Ask them if they prefer to pay less or to have a project with better quality,
- At the end, if you haven't spent a lot of money of your customer, you may suggest new features or improvements.
This doesn't work with every customer. Some just want the work to be done and don't care about quality. Others just want the lowest price. Others are unable to tell how much money do they have. Others want to be sure to pay the minimum. Others are afraid you will spend more than need.
But you don't have to force your customers to give you the two amounts. Make it optional, and use traditional approach with the customers who can't give you the amounts.