Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

3 Answers

up vote 2 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
add comment

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) –  Evan Dec 3 '12 at 23:57
add comment

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? –  Evan 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) :) –  Evan 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 –  Evan 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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.