The `-D` option to curl takes a filename as an argument.
That is, You need to type `curl -D <file>` for it to store the header in the <file>.
In *nix OSes, the `-` character is a special case. When used in place of a file, it tells the program to write to the standard output (STDOUT).
Typing `curl -D-` is telling curl to write the headers to the standard output.
Removing the `-` in your example makes curl think You want to save the headers in a file named `-u`. This makes curl think You are trying to visit the url <username> at the port <password> (Because you would write it <url>:<port> if that is what you wanted to do.)
There is probably a file in Your present working directory named `-u` that you can safely delete. If you type a filename after the -D option, the error should go away.
Code:
curl -k -D foo -u <username>:<password> "https://url"
(My own assumptions here, obviously. YMMV.)