Telnet connection on localhost Refused - php

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

Related

Pagekite error: FAIL: localhost:8080 is down

When i try to create a tunnel to my localhost:8000 with $ pagekite.py 8080 xxxx.pagekite.me, i get a error when someone trys to connect: (FAIL: localhost:8080 is down). I created the server on my local machine with: $ php -S localhost:8080. When i try to access to the site on my local machine with http://localhost:8080, everything works perfectly.
Your webapp is probably listening on IPv6 localhost (::1) and pagekite.py is trying to connect to IPv4 localhost (127.0.0.1).
Forcing your webapp to listen on 127.0.0.1 should fix this.
$ php -S 127.0.0.1:8080

Persistent connection of websocket into live server

I have implement rachet websocket with codeigniter and it's working fine in localhost. This is a main server.php that we need to run from terminal / cmd
require __DIR__ . "/../vendor/autoload.php";
use Chat\Chat;
use Ratchet\Server\IoServer;
use Ratchet\Http\HttpServer;
use Ratchet\WebSocket\WsServer;
$server = IoServer::factory(new HttpServer(new WsServer(new Chat)), 2000);
$server->run();
I run this file from cmd with following command
D:\wamp\www\my_project\api\application\third_party\Realtime\bin server.php
This command start socket and now any user access my site through browser then they are connect with socket and I can sent message to him. When I close terminal / cmd then socket close automatic.
Now my development is done and I upload all source on "openSuse" server. So my question is how I run above server.php file on live server ? (for example amazon ec2 OpenSuse server). because server don't have terminal / cmd.
Also this should run persistent so any time any user access my site they are connect to server and I will send him message.
I try many way but it's not working any how.
after installing haproxy i create confing file haproxy.cfg into /etc directory
In this file i have set
backend ws
server ws1 my_public_ip:2000
backend www
timeout server 30s
server www1 my_public_ip:80
Here port 2000 is websocket port and port 80 is my apache port
I also try with 127.0.0.1 but it gives following error
[ALERT] 293/101352 (2291) : Starting frontend public: cannot bind socket [0.0.0.0:80]
After skip this error i create supervisor.conf file in /etc/ directory and add rachet program as per your given link
Here in command i gave full path to server.php file
command = bash -c "ulimit -n 10000; exec /usr/bin/php /srv/www/htdocs/ci_chat/application/third_party/Realtime/bin/server.php"
But it gives me following error
Error: Another program is already listening on a port that one of our HTTP servers is configured to use. Shut this program down first before starting supervisord.
My apache run on port 80
pgsql run on 5432
Now i can not understand which service need to shutdown.

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

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

How to enable PHP's built-in web server on wercker

I have setup my wercker.yml file with the following step midway:
- script:
name: Serve application
code: php -S localhost:8000 >> /dev/null &
That appears to run, however, in another step when I try cURL to http://localhost:8000 I get the following:
curl: (7) Failed to connect to localhost port 8000: Connection refused
It does it for all ports, not just 8000. Has anyone else managed to get PHP's in built server working in wercker, or open any ports?
Assuming you're using the wercker CLI and trying to set up a development pipeline, you need to use wercker dev with the --publish 8000 argument. This will forward the traffic from your host on port 8000 to the container on port 8000.
Also, if you're using boot2docker, you can't specify localhost, since boot2docker spins up a VM that runs docker. In that case you'll need to use your boot2docker IP, which you can find by running the boot2docker ip command.

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.

Categories