curl: (7) Failed to connect to localhost port 3000: Connection refused
Asked Answered
M

4

7

I typed this into terminal

$ curl -X POST http://localhost:3000/voice

and I got this error

curl: (7) Failed to connect to localhost port 3000: Connection refused

I've looked everywhere for a solution I can understand, but found no luck. Any help is appreciated.

Matrilineage answered 21/6, 2016 at 19:32 Comment(4)
do you have a server running on that port? because that's the error you'll get if you don'tHoitytoity
seems that nothing is running on that port or localhost is not in hosts file... try 127.0.0.1 instead of localhostCooke
Try checking if anything's listening on port 3000. Run lsof -iTCP -P -n. There may be quite a few things with open connections, so piping it through grep 3000 may help. If nothing shows up, make sure your server's running.Monetta
Hi, you should start local host with port 3000. if you are in node.js, you should type in command prompt. npm start.Babbage
O
2

I think it's because you have not started your local host with port 3000.

Try http://localhost:3000/ in your browser. See if it's connected.

If not, you need to start your local host first with port 3000.

Ocrea answered 7/8, 2018 at 4:26 Comment(0)
I
0

I think port 3000 is not open on the host. To see if something is listening on a certain port or open at all, you can use netstat -tlpen | grep 8080 or nc -vz [host] [port].

Isfahan answered 1/5, 2021 at 7:44 Comment(0)
C
0

it's needed to start the localhost with port 3000: 1-Run the server, if for example with a node server: $ node nameOfCode.js 2-then in a new terminal type curl -X POST http://localhost:3000/voice i did it and it worked for me

Copyreader answered 27/12, 2021 at 20:51 Comment(0)
K
-1

In my case I was running my laravel app with docker on port 8000 and other node.js app on port 3000 locally

Then I've realised that app from docker couldn't connect to local instance

It got fixed when I've changed

http://localhost:3000

to

http://host.docker.internal:3000
Kastner answered 22/8, 2024 at 13:17 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.