curl: (7) couldn't connect to host What is wrong in my settings?
Apparently, your server is not listening on port 9201
.
You need to first verify that if your server has successfully started listening on your designated port. As yudong shen suggested, you may use netstat
command to verify this.
For example:
To list all the <ip:port>
pairs along with their state and their respective process:
$ netstat -anp
Observe the Local address
, State
and PID/Program name
columns to identify your process and its designated <ip:port>
with state.
To check if the designated port is used by a process irrespective of its state:
$ netstat -anp | grep :9201
To make sure that the port is open for listening:
$ netstat -anp | grep LISTEN | grep :9201
You may also use a REST Client such as Google Chrome's Postman to interact with your web server from a GUI.
Admin
Updated on June 14, 2020Comments
-
Admin almost 4 years
When I run command:
$ curl http://localhost:9201
I get this error:
curl: (7) couldn't connect to host
Next when I run command
curl
with verbose flag i.e.:$ curl -v http://localhost:9201
It ends up with error:
* About to connect() to localhost port 9201 (#0) * Trying ::1... Connection refused * Trying 127.0.0.1... Connection refused * couldn't connect to host * Closing connection #0 curl: (7) couldn't connect to host
I really cannot understand why this error happens. What is wrong in my settings? How can I fix this?