I just set up ElasticSearch on my server, but I cannot seem to connect to it remotely (default is port 9200). I can connect to it via localhost, but I cannot connect to it remotely when I specify the IP address. I assume this is because the port is closed (but I'm not sure). Thus, I would like to know how to check whether or not a given port is open, and additionally, how to open a port that may be closed.
To check the open ports on your server you can do this as sudo:
To open a TCP port (port 9200)
iptables -I INPUT -p tcp --dport 9200 --syn -j ACCEPT
For UPD port you would use (port 9200)
iptables -I INPUT -p udp --dport 9200 -j ACCEPT
Finally, to save the changes use:
service iptables save
However, as @Codezilla mentioned, you are probably behind a router and need to forward the ports.
Sounds like you're behind a router, you probably need to forward the ports. If this is the case, check out this site for a pretty easy walkthrough of how to setup port forwarding. You have to forward ports on your router in order for people from outside your network to access certain applications/services on certain ports. Basically it tells the router that whenever someone wants to view the web server at your ip address for instance (or that ElasticSearch applications), it knows to forward that request to the appropriate computer behind your router.
There are a few ways to go about doing this..
First off, which operating system are you hosting ElasticSearch on? Windows? Linux? When you say remotely, do you mean machines other than your machine or do you mean computers not connected to your LAN out on the internet?
For future reference, please say what Operating System you are using IN THE POST. I did not notice the CentOS tags until I was 20 minutes into writing a response for how to do this in windows...
sudo iptables -L
do you see a rule allowing port 9200 in that list? if not, you probabally just have to add a new rule to allow connections on 9200 (TCP i am going to guess)
try this (as root)
iptables -A INPUT -m tcp -p tcp --dport 9200 -j ACCEPT iptables -A INPUT -m udp -p udp --dport 9200 -j ACCEPT
If you have permission issues you could try using
sh to save your
sudo sh -c "iptables-save > /etc/iptables/rules.v4"