My hosts file maps 127.0.0.1 to localhost.
127.0.0.1
localhost
$ curl -I \'localhost\' curl: (7) Failed to connect to localhost port 80: Connection re
I also had problem with refused connection on port 80. I didn't use localhost.
curl --data-binary "@/textfile.txt" "http://www.myserver.com/123.php"
Problem was that I had umlauts äåö in my textfile.txt.