curl: (6) Could not resolve host: application
CurlCurl Problem Overview
Getting url: (6) Could not resolve host: application error after this command :
curl -i -H 'Content-Type: application/json' -d '{"Code":"FR","Name":"France"}' http://127.0.0.1:8080/countries
Full error log:
curl: (6) Could not resolve host: application
HTTP/1.1 415 Unsupported Media Type
Content-Type: application/json; charset=utf-8
X-Powered-By: go-json-rest
Date: Sat, 02 Apr 2016 05:31:20 GMT
Content-Length: 73
{
"Error": "Bad Content-Type or charset, expected 'application/json'"
}
What's wrong with this command?
Edit:
I solved my problem editing like this in windows : "{/"Code/":/"FR/"}"
Curl Solutions
Solution 1 - Curl
In my case, putting space after colon was wrong.
# Not work
curl -H Content-Type: application/json ~
# OK
curl -H Content-Type:application/json ~
Solution 2 - Curl
It's treating the string application
as your URL.
This means your shell isn't parsing the command correctly.
My guess is that you copied the string from somewhere, and that when you pasted it, you got some characters that looked like regular quotes, but weren't.
Try retyping the command; you'll only get valid characters from your keyboard. I bet you'll get a much different result from what looks like the same query.
As this is probably a shell problem and not a 'curl' problem (you didn't build cURL yourself from source, did you?), it might be good to mention whether you're on Linux/Windows/etc.
Solution 3 - Curl
I replaced all the single quotes ['] to double quotes ["] and then it worked perfectly. Thanks for the input by @LogicalKip.
Solution 4 - Curl
Example for Slack.... (use your own web address you generate there)...
curl -X POST -H "Content-type:application/json" --data "{\"text\":\"A New Program Has Just Been Posted!!!\"}" https://hooks.slack.com/services/T7M0PFD42/BAA6NK48Y/123123123123123
Solution 5 - Curl
I was getting this error too. I resolved it by installing: https://git-scm.com/
and running the command from the Git Bash window.
Solution 6 - Curl
For my issue using curl on Windows 10 with the environment variable already setup,
curl -X POST -H "Content-Type:application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"eth_blockNumber\",\"params\":[],\"id\":83}" https://some-node-url.com
I needed to replace all single quotes '
with double quotes "
even though the example for the blockchain I was trying to curl to had a single quote.
And also add \
in front of all the double quotes inside the param brackets {}
Solution 7 - Curl
In my case, it was a missing line break that added unneeded parameters due to a bad copy and paste.
I followed a guide at https://pytorch.org/docs/stable/notes/windows.html#include-optional-components which looks like this when you copy it right here without any editing:
> REM Make sure you have 7z and curl installed. > > REM Download MKL files
curl https://s3.amazonaws.com/ossci-windows/mkl_2020.0.166.7z -k -O 7z x -aoa mkl_2020.0.166.7z -omkl
Output:
C:\Users\Admin>curl "https://s3.amazonaws.com/ossci-windows/mkl_2020.0.166.7z" -k -O 7z x
-aoa mkl_2020.0.166.7z -omkl
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 103M 100 103M 0 0 5063k 0 0:00:21 0:00:21 --:--:-- 5629k
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0curl: (6) Could not resolve host: 7z
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0curl: (6) Could not resolve host: x
curl: (6) Could not resolve host: mkl_2020.0.166.7z
There is actually a line break before "7z", with "7z" as the executable (and before, in addition to adding curl to your user PATH
, you need to add 7z to the user PATH
as well, for example with setx PATH "%PATH%;C:\Program Files\7-Zip\"
):
> REM Download MKL files
>
> curl https://s3.amazonaws.com/ossci-windows/mkl_2020.0.166.7z -k -O
>
> 7z x -aoa mkl_2020.0.166.7z -omkl
Solution 8 - Curl
In my case, I copied the curl command from Confluence to TextEdit. After spending almost an hour, and trying to paste the command in different text editors in order to sanitize, finally, PyCharm helped me (IntelliJ should help too)
After pasting it in PyCharm I got to see the error
After removing these "NBSP" (non-breaking spaces), the command started running fine.
Solution 9 - Curl
Windows consoles usually doesnt interpret double quotes correctly in a JSON array, so you can solve it adding a slash / before double quotes.
Solution 10 - Curl
In ubuntu like system this mainly occurs when we don’t have nameservers in the /etc/resolv.conf
So, we added the following line in the file.
nameserver 8.8.8.8
Then, this fixed the error and the host started resolving.