Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 3 down vote accepted

To check the open ports on your server you can do this as sudo:

iptables --list

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.

share|improve this answer

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.

http://portforward.com/english/routers/port_forwarding/routerindex.htm

share|improve this answer
    
Thank you for that explanation on port forwarding, but how can I check to see if a port is open (specifically, with bash) – Eva Dec 3 '12 at 23:57

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...

Try

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
share|improve this answer
    
Hi Richie, I'm dealing with CentOS (server), and Ubuntu (client). But that seems like a very good answer for Windows users. Do you happen to know how to do this on Linux? – Eva Dec 4 '12 at 0:05
    
Sorry about the OS thing, I tagged centos when I created the post, but I'll be sure to be more specific in the question next time I post, your time / effort is very much appreciated (upvoted) :) – Eva Dec 4 '12 at 0:09
    
iptables -A INPUT -m tcp -p tcp --dport 9200 -j ACCEPT iptables -A INPUT -m udp -p udp --dport 9200 -j ACCEPT – Richie086 Dec 4 '12 at 0:11
    
The server is located in a data centre, the client is on another network – Eva Dec 4 '12 at 0:12
    
ah, the answer (by greg, above) is exactly right - he deserves the points. thanks for the upvote tho! – Richie086 Dec 4 '12 at 0:14

If you have permission issues you could try using sh to save your iptables configuration:

sudo sh -c "iptables-save > /etc/iptables/rules.v4"
share|improve this answer
    
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. - From Review – Enigma Mar 3 at 16:07
    
i would like to comment the post, but for now i cant. never the less i would like to share my thoughts. any ideas to make it suitable? i just want to help. – DaviideSnow Mar 3 at 21:18
    
Each answer needs to stand on it's own. If you want to leave a comment but not a full answer, you'll need to work towards earning enough reputation to leave comments. – Enigma Mar 3 at 21:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .