Getting curl: (6) Could not resolve host: localhost
I'm facing an issue when calling a localhost url through curl
. I did check this question but it didn't help me.
My curl command:
curl --data "ip=127.0.0.1&device_type=web" http://localhost/api/users/getToken.json
Also tried the solution in this selected answer : https://stackoverflow.com/a/40078901/1225070
curl -H "Content-Type: application/json" --data "ip=127.0.0.1&device_type=web" http://localhost/api/users/getToken.json
However, the above command is working if I run it using the IP address
curl --data "ip=127.0.0.1&device_type=web" http://192.168.1.1/api/users/getToken.json
Any help why this is not working when using localhost?