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

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.

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.

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].

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

Related

Connecting to MySQL Server on Ubuntu not possible

I have set up a raspberry PI 4 with Ubuntu. Apache, PHP, mysql and phpmyadmin are installed and working fine. So when I am trying to connect from another network with my windows device over MySQL Workbench there is an error occuring.
error
Checked: port forwarding on port 80 is open. checked binding ip in mysqld.conf (maybe I made a mistake there) when I try to change the port in this configuration file to 80 and restart "sudo service mysql restart" this error occure "Job for mysql.service failed because the control process exited with error code"
So maybe mysql is not listening to port 80. I have checked sudo lsof -i :80. Only found records from apache listening to port 80.
I am trying for three days now to connect to the database.
Thank you for your help guys!
By default, mysql listens on port 3306, so if you are trying to connect directly to mysql, that could be the issue. Port 80 and 443 are for http/https respectively.
You can't set the port to port 80 because apache needs that port to listen for http requests.
Try setting the port back to 3306 on the mysql host machine and seeing if that works. You may also need to open that port on the host machine as well.

Remote MySQL Server not responding

I'm having issues connecting to my AWS EC2 Server holding a MySQL Server.
Here's my Response from mysqli_connect
p#xxx.com [~/app]# php checkmysqlremote.php
Error: Unable to connect to MySQL.
Debugging errno: 2002
Debugging error: Connection refused
Here's my netstat -tuplen on the EC2 Server containing the MySQL Server
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 999 20299 1378/mysqld
As you can see its binding to the 0.0.0.0 address correctly.
I enabled the 3306 port in inbound rules for EC2.
on the server making the request handshake, I ran:
curl -s example.com:3306 >/dev/null && echo Success. || echo Fail.
which resulted in Fail.
I also ran it on the local server instance and it responded with Success.
I also ran nmap on the server making the handshake,
nmap -p 3306 example.com
Nmap scan report for example.com (1.1.1.1)
Host is up (0.048s latency).
PORT STATE SERVICE
3306/tcp filtered mysql
Nmap done: 1 IP address (1 host up) scanned in 2.03 seconds
Lastly, I tried adding the following rules in iptables:
iptables -A INPUT -i eth0 -s "example.com" -p tcp --destination-port 3306 -j ACCEPT
and
sudo iptables -I INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT
I don't know what to do at this point.
UPDATE
I tried pinging the EC2 server from the remote server and it did not return anything. At this point i think the issue is with EC2.
Try adding the follwing GRANT to your user:
GRANT ALL PRIVILEGES ON *.* TO 'user'#'ipadress'
Sounds like the port might not be getting forwarded correctly? One thing to try might be to put an Amazon Elastic Load Balancer in front of the instance. Then you can forward port 3306 for the MySQL connection.

Telnet connection on localhost Refused

EDIT:
I want to telnet into my web server on localhost, and request my php file from command line:
I have:
1) cd'd into the directory I want to serve, namely "/www" (hello.php is here)
2) run a server at directory www: python -m SimpleHTTPServer
3) telnet localhost 80
but "connection is refused". what am I doing wrong?
You're probably trying to connect to a wrong port. Check with netstat -lntp which port is your http server listening on. The process will be listed as python/pid_number.
If you're using Linux then try this:
$ telnet localhost 80
GET /hello.php

cURL couldn't connect to host, but it connects to my domain address

I am new to Linux. I had the php project in the Linux server. I am using the cURL command in my php page to access Google, but it says it couldn't access the host.
From the command line, I can ping the Google site, while cURL and Wget commands fail.
I had checked the firewall: selinux=disabled and selinuxtype=targeted.
Try this command from a terminal
telnet www.google.com 80
Do you get any output? Like Connected to www.google.com? If not, then the outgoing access to google.com on port 80 is blocked.
Ping uses the ICMP protocol. cURL (and telnet) uses TCP on port 80 or 443.

"Apache started [Port 80] Busy..."-This type of error shows

My xampp is not working. I am getting the following error
Apache started [Port 80] Busy...` error is shown in xampp-control.
While Im typing in browsers url localhost/phpmyadmin, it shows Not Found HTTP Error 404. The requested resource is not found.
Maybe port 80 is used by another program.
On Windows you can see if there is any other program using port 80 with the command
netstat -a -b
You can also try using a different port than port 80 and see if that works. See:
https://stackoverflow.com/a/15029626/2802916
Use this command to find a port which is using:
netstat -an | find "80"
If the result like this, some programm is using 80 port
TCP 127.0.0.1:80 0.0.0.0:0 LISTENING
Use netstat -o -n -a | findstr 0.0:80 to find the process which use port 80 and stop it.
Otherwise, you can change the port in httpd.conf to something else, after change, save it and restart apache.
Start->Accessories right click on "Command prompt", in menu click "Run as Administrator" (on Windows XP you can just run it as usual), run netstat -anb then look through output for your program.
BTW, Skype by default tries to use ports 80 and 443 for incoming connections.
You can also run netstat -anb >C:/ports.txt It will print info to .txt file related to all ports and you can search easily.

Categories