cURL does not respect named services. In fact, it seems to ignore any non-numeric string passed after the : in the hostname, and revert to port 80.
On Ubuntu 12.04 and 14.04, if I curl for example:
$ curl localhost:discard/
I would expect for it to attempt to connect to port 9 (according to man 5 services and the contents of /etc/services). Instead, it exits with the error:
curl: (7) Failed to connect to localhost port 80: Connection refused
Should I expect this to work?
curl requires you to provide a "URL", the ones we support are defined mostly in RFC3986 and as section 3.2.3 in there says:
"an optional port number in decimal"
Thus, you cannot provide any port in a URL that isn't a decimal number. A service name is not a legitimate port number and thus curl does not support that. It simply is not expected to work!