App is Listening, No Iptables, Yet Port is Closed - linux

I have an application that is listening on port 7077 on a server:
netstat -a -W | grep 7077
tcp6 0 0 spartacus.servile.war:7077 [::]:* LISTEN
I can connect to the port with telnet on "spartacus", and can run a client program using the port on "spartacus" also, but I cannot connect to 7077 from another computer on the same LAN with telnet or a client program.
Spartacus is running xubuntu 12.04, iptables is not installed.
If I run nmap port 7077 is closed:
nmap -p 7077 192.168.0.113
Nmap scan report for Spartacus.servile.war (192.168.0.113)
Host is up (0.000061s latency).
PORT STATE SERVICE
7077/tcp closed unknown
nmap also reports that this port has no filtering:
nmap -sA -p 7077 192.168.0.113
Nmap scan report for Spartacus.servile.war (192.168.0.113)
PORT STATE SERVICE
7077/tcp unfiltered unknown
For what it's worth, running traceroute on the other machine gives this:
$ traceroute -p 7077 192.168.0.113
traceroute to 192.168.0.113 (192.168.0.113), 64 hops max
1 192.168.0.113 0.243ms 0.140ms 0.161ms
Why is port 7077 not open, and how can I open it?
I have Googled extensively but results either want to HELP me close ports, or assume I have iptables running, or think I want to find an app that is listening, or... (the list goes on) but not this situation.
The app is Spark Master 1.3.1, but this is not a Spark issue, I am (almost completely) sure.

I'm confused by the problem for a whole day, but I fixed it just now, you can cat /etc/hosts, you can modify the second line of this file to your local ip, then it works. I don't know why that works, but it do.

Related

How to open port 80 for node server on local machine?

How can I use the port 80 on my local Linux machine as the port of my node server?
The netstat command netstat -ptuln says the following about this port, while the node server is running:
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:80 0.0.0.0:* LISTEN -
I found on this site some recommendations for the command sudo iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT. I executed this command but when I make a request with curl (curl 1.97.xxx.xxx.xx) it keeps responding with curl: (7) Failed to connect to xxxxxx port 80: Connection refused.
But using curl the following ways works: curl 0.0.0.0:80 or curl localhost:80.
My conclusion is, that I somehow have not opened the port correctly, but all I could find on the internet repetitively is the command I mentioned earlier.
I am aware of the fact that I could fix this easily by using an apache server, but I would like to make it without it.
Thank you!
Paste the output from
netstat -ptuln
command.I think the problem is that your web server runs on local address and can not be reachable for other machines in network.

Can't use port 8080

When I'm trying to run a service (RavenDB) on port 8080 it stops and the Windows Logs show the following error:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Net.HttpListenerException: Failed to listen on prefix 'http://+:8080/' because it conflicts with an existing registration on the machine.
Acccording to IIS and netstat -an | find "8080" the port is currently not in use.
If I change the port to any other, the problem disappears.
Port 8080 may actually be in use. To replicate another answer
netstat -a only lists connected sockets and listening socket.
-a Displays all connections and listening ports. Neither
connect nor listen was called on your socket, so it falls outside the
purview of netstat -a.
However, since Windows 10, you can use netstat -q.
-q Displays all connections, listening ports, and bound
You could also try to view the port using tcpview from the SysInternals suite. Sort by port number. It will also tell you the process using the port, which you can then kill.

cannot open up port using iptables to use rstudio server

I am currently trying to open port 8787 for rstudio server. I have set this up on an ubuntu host, and want to point my browser at the ip address of the ubuntu host, using port 8787 to direct it to rstudio. I can do this from the host machine, but no such luck using a different computer.
When I do
netstat - peantl | grep ":8787"
I get nothing returned, unlike when checking port 22 which is confirmed as listening. I can there ssh from external machines into the ubuntu host.
So I tried to open up port 8787 with iptables:
sudo iptables -A INPUT -p tcp --dport 8787 -j ACCEPT
command runs fine, but then re-checking with netstat I still do not get any output (I was expecting similar output to port 22 as mentioned previously)
I also allowed port 8787 on ufw:
sudo ufw allow 8787
using gufw it confirms port 8787 is open.
What could be the issue? If my network has restricted port 8787 how can I tell? Am I allowing port 8787 correctly with iptables?
Thanks.
All your iptables and ufw commands are doing is opening ports in the firewall itself. The fact that there is no output from the netstat|grep line means that the rstudio software does not actually have the port open for anyone to connect to. This is the issue you need to fix first.

Enable HTTP TCP connection requests in Arch Linux for neo4j

My laptop is running a local neo4j server. I can use it with localhost:7474 but when i try connecting it with 192.168.1.12:7474 it is unreacheable.
Turns out linux is blocking connections other than web server port 80. Because i can access my Apache server on 192.168.1.12/
I am trying to allow TCP connections on port 7474 by using
iptables -A TCP -p tcp --dport 7474 -j ACCEPT
but it gives a response as -
iptables: No chain/target/match by that name.
How can i make other clients access neo4j server running at my laptop on port 7474. My laptop IP addr is 192.168.1.12.
I doubt that it is blocking it. Probably your neo4j server is only running at 127.0.0.1. You can check this out with netstat -nplt: you will probably see something (the apache) listening on 0.0.0.0:80 or :::80 (e.g. catchall address) but on port 7474 you will probably only see 127.0.0.1:7474 or ::1:7474. If this is the case you need to reconfigure your neo4j server to listen not only on localhost (don't know how, checkout the documentation).
Okay. I had uncommented the webserver address line but it still wasn't working.
So i reinstalled neo4j. That solved it. Weird but worked.

netstat commands to run on unix server, what commands should I use for my use-case and why?

Sorry in advance for such a noob question, but I'm certainly a noob.
My question is what does it mean to LISTEN or ACCEPT on a port as it relates to my example?
EXAMPLE:
I have a tomcat server, and It will use port 8080. I want to make sure that port is available for me to use.
What commands should I perform on my unix server and why?
what information would a command like this give me: netstat -an | grep LISTEN
If a port shows up as LISTEN in netstat, it means the port is in use by a server process, so you can't use it. Here is an example:
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
which shows that port 631 is in use.
Ignore the UNIX type sockets at the end - they are irrelevant.
For checking port 8080 is in use or not, you can simply use the command netstat -an|grep 8080. If you get an output in below format, that means 8080 is already in use and you need to assign a new port for the tomcat.
# netstat -an
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN
Netstat command displays various network related information such as network connections, routing tables, interface statistics, masquerade connections, multicast memberships etc,
a option with netstat will give you both listening and non listening ports
n option when you don’t want the name of the host, port or user to be displayed, use netstat -n option. This will display in numbers, instead of resolving the host name, port name, user name. This also speeds up the output, as netstat is not performing any look-up.
For more understand the use of netstat command here are its options:
-a : All ports
-t : Ports TCP
-u : Ports UDP
-l : Listening ports
-n : IP address without domain name resolution
-p : Name of the program and it associated PID
So:
-To display all port (TCP & UDP), PId with the associated name of the program :
$ netstat -paunt
-To display all Listening ports (TCP), PId with the associated name of the program : (and we can also filter with the grep command)
$ sudo netstat -plnt | grep ':80'
I hope it will be helpful :)
You can also use telnet to check if the port is open and listening e.g,
Zeeshan$ telnet google.com 80
Trying 173.194.35.5...
Connected to google.com.
Escape character is '^]'.
I am telnetting google.com on port 80. If you see the third line in the output, you will notice it says it is connected with the Google's web server. The same way you have a JAVA application server called Tomcat and it is listening on port 8080. In fact it is asking clients to connect to it on port 8080 so it can give away the JAVA services to client. When I will use from a client side telnet localhost 8080 I will be connected the same way I have connected with Google's web server on port 80. Provided that Tomcat is running and listening on port 8080. If port 8080 is not free and occupied by some other application you can simply change the port 8080 to another free port. Telnet should give you the following status:
accepted (connected), refused, and timeout
connection refused - nothing is running on that port
accepted - some application is running on the port
timeout - a firewall is blocking access
So now there are two possible ways to check. From the same machine you are running Tomcat server:
telnet localhost 8080
Of if you want to check it from some other machine or outside of the network:
telnet 192.168.1.1 8080
I hope that helps.
use can also run the below command, it will list the Port and corresponding PID, if any process is using those ports
netstat -tulpn

Resources