Linux – Port not accessible on Linux server

iptableslinuxport

I started local server using php on my server

php -S 0.0.0.0 8283 -t testServer/

using curl localhost:8283 I am able to get the result of the index.php file

but when I access it using my server ip I am not able to access that port .

Any when I do netstat -tuplen . I can see that port as well .

How can I make port 8283 available through http request ?

I have used this

# /sbin/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 8283 -j ACCEPT
# service iptables save
# service iptables restart 

and still it did not work

And this is output from telnet on my server

telnet XX.XX.X.XXX 8283
Trying XX.XX.X.XXX...
Connected to XX.XX.X.XXX.
Escape character is '^]'.
GET /

HTTP/0.9 200 OK
Connection: close
X-Powered-By: PHP/5.5.19
Content-type: text/html

Hello World !Connection closed by foreign host.

this one is from my PC

telnet XX.XX.X.XXX 8283
Trying XX.XX.X.XXX...
telnet: Unable to connect to remote host: No route to host

NMAP Result

sudo nmap -p 8283 XX.XX.X.XXX

Starting Nmap 5.21 ( http://nmap.org ) at 2015-02-04 19:18 IST
Nmap scan report for srv1.domain.com (XX.XX.X.XXX)
Host is up (0.035s latency).
PORT     STATE    SERVICE
8283/tcp filtered unknown

Nmap done: 1 IP address (1 host up) scanned in 0.37 seconds

IPTABLES OUTPUT

/sbin/iptables -L -n
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:8282 
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:8283 state NEW,ESTABLISHED 

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination        

Best Answer

Your localhost parameter to the -S option is telling PHP to only listen to localhost, or 127.0.0.1. If you want it available externally, you need to use either the external IP address / hostname or "0.0.0.0", though a quick read through the manual page doesn't explicitly indicate 0.0.0.0 will work.