This question receives many different answers, from thousands of pounds to nothing. So what’s really going on?
First of all, actually publishing your book costs nothing. Uploading files to Amazon and creating either ebook or print version does not involve a fee.
But it’s not as simple as that. There needs to be quality control of what you’re uploading. Has your work been reviewed, to ensure that it makes sense, that it’s well written, that it doesn’t contain silly typos or other errors that will put your reader off? Will your cover design attract readers to your book? Is your layout correctly formatted for whatever platform you want to publish on?
If you’re self-publishing, then all those quality control issues come down to you. It’s your responsibility to get an editor to go through your work, to get a good cover design done, to ensure the formatting is correct.
Some of these you can do yourself, if you have the skills, but editing is one of those jobs that must be done by someone else to be done well; you are too close to your own work, and just can’t see what you’ve actually written as opposed to what you think you’ve written.
Even cover design and formatting are worth paying experts for; while anyone can throw a cover together, books are a competitive market, and your book deserves a cover that will attract the reader. Likewise, formatting can be fiddly and frustrating if you’re new to it. Why not spend your time writing, and pay the experts to do their job?
There are publishing companies around who offer to do all this as a package deal, for a price. Be very wary of these; generally, they make their money from the services they sell to you, not from their share of the books sold (although they take a good slice of that too). You risk paying a lot of money for services you could have got cheaper separately, and losing control of your book as well.
What if you can’t afford to pay an editor, cover designer etc?
The answer then is not to just put it out anyway. The quality is likely to be poor, and that will put readers off anything else you write, and weaken the reputation of self-published books generally.
Traditional publishing involves a publisher liking your book enough to invest money in it. They keep part of the sales, yes, and you might lose some of the control over your book, but they are the ones who take the financial risk. Remember, if they ask you for money to publish, they are not a traditional publishing company.
So in the end it comes down to this: please either be prepared to invest money as well as time in your writing to ensure quality (after all, you’re expecting others to invest money in your books!), or find someone else who is willing to do so.