error on local PHP server: localhost refused to connect - php

I am trying to run a development server on my Mac. I have been able to do so before with no issues. I'm not aware of any changes I've made, but now the server starts, but I'm unable to access it from a browser:
❯❯❯ php -S localhost:8000 ⏎
PHP 5.6.30 Development Server started at Mon Oct 16 18:06:16 2017
Listening on http://localhost:8000
I get this message from the browser:
This site can’t be reached
localhost refused to connect.
No noise from the server process at the command line.
My /etc/hosts file has the following line:
127.0.0.1 localhost
What am I missing?

Related

Yii server on local

guys. Good day.
I have an issue with Yii server on local.
I had to launch the Yii server on local and I typed command like below
> php yii serve --port=8081
Server started on http://localhost:8081/
Document root is "G:\yii\basic/web"
Quit the server with CTRL-C or COMMAND-C.
[Sun Jun 26 10:57:24 2022] PHP 7.4.5 Development Server (http://localhost:8081) started
This made port 8081 listening on my PC.
I checked that with
> netstat -n -a -o
...
TCP [::1]:8081 [::]:0 LISTENING 13844
...
command.
It showed that port 8081 was listening.
But then when I tried to access it on Chrome browser with URL
localhost:8081
it gave me the issue below.
This site can't be reached
localhost refused to connect
Try:
Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED
Disabling firewall did the same either.
What wrong? :( Any advice would be appreciated.

php Webserver on local machine. Pagekite error: FAIL: localhost:8080 is down

When i try to create a tunnel with $enter code here pagekite.py 8080 xxxx.pagekite.me , and someone trys to connect, there is this error: (FAIL: localhost:8080 is down). I created the website on my local machine with $ php -S localhost:8080. When i try to connect to the server on my local machine with http://localhost:8080 the site works perfectly.

Webserver hostname issue after Win10 April update

I have web server in my local network (Apache/2.4.10 + PHP 5.6.36 on Raspbian GNU/Linux 8 (jessie) 4.9.35-v7+ on Raspberry Pi) with hostname webserver. Then I'm also using a local webserver (localhost) on my workstation (Win 10 Home 64bit + Apache/2.4.25 + PHP 7.1.4).
After update to Win 10 "April update" (1803) I have this issue: when a PHP script on my localhost (i.e. workstation) tries read some file from webserver via file_get_contents()
$content=file_get_contents("http://webserver/file.php");
I get this error:
php_network_getaddresses: getaddrinfo failed: The requested name is valid, but no data of the requested type was found.
When I change hostname to IP address (http://192.168.1.100/file.php) then it works. Also there is no problem when I put http://webserver/file.php directly in my broswer (on workstation). The problem is only when a script from localhost (workstation) is trying to reach address on webserver with hostname in address.
Before Win 10 April update everything worked fine, so where can be a problem? I have installed all Windows updates but it didn't help...
Check your HOSTS file in C:\windows\system32\drivers\etc\HOSTS
Some Windows updates replace this file with a default, which would explain why you can no longer access the server as there will be no reference to it in the HOSTS file.

I can not connect laravel as django is already in my pc

I installed Django on my PC, but I want to install Laravel also. But my localhost didn't connect. Whenever I want to connect to Laravel in localhost it gives an error like
"Laravel development server started:
[Thu Oct 5 01:41:01 2017] Failed to listen on 127.0.0.1:8000 (reason: An attempt was made to access a socket in a way forbidden by its access permissions."
How can I fix it?

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

Categories