-1

I wanted to open a specific port in linux server for my new application to use. But if i use 8080 as a port number it is working perfectly. instead of 8080 i wanted to use separate port say, "8301". How can i achieve that.

I am quite new to these kind of server admin tasks.

Any help would be greatly helpful.

Ravi kumar
  • 170
  • 1
  • 2
  • 15
  • 1
    Hello Ravi. It would be helpful to know more about what you are attempting to accomplish. What application are you working with? What have you tried so far? What will be connecting to your port? From where? – Forty3 Apr 26 '17 at 04:48
  • I wanted to configure two applications on different ports. one for mongodb and the other one for My web application. For Mongodb, as a default i am trying to connect by using port no as "27017", but it is saying Network is unreachable. Then i guess some thing wrong with the port no, and i have tried like "sudo netstat -lptu" to get the all listening port numbers. i did not find 27017 on the result. that is why i wanted to open that port no. same issue i am facing for my web application too. Please suggest me to proceed further. – Ravi kumar Apr 26 '17 at 04:59
  • When you say you want to *open* a port on your server, that does not really make sense. A program can create a socket and listen on a specific tcp port, yes, but that's it. If you can't reach the port from the outside, you have some kind of firewall blocking access to this port. If your application does not start listening at all, it's a problem with your application. Please check the output of *netstat -tan* to get a complete list of TCP sockets (the command you gave lists UDP). – Rob Apr 26 '17 at 05:08
  • @Ravikumar - Your search will be application specific. Or, more specifically, if you search application specific, you will likely find your answer (e.g. http://stackoverflow.com/questions/9154030/unable-to-connect-to-mongodb) – Forty3 Apr 26 '17 at 05:09
  • @Robert, i have tried your command __netstat -tan__ , yes it is giving all TCP sockets. But i suspect, whatever ports i required has some firewall blocking issue. could you please help me to enable access for the required port numbers by changing the firewall settings. – Ravi kumar Apr 26 '17 at 05:21

2 Answers2

1

To connect to the mongo from another server/network IP address needs to be binded.In mongod.conf file there will be a line bind_ip = 127.0.0.1.If you are accessing mongo from outside ,you should bind the destination IP address.

Ex:bind_ip = 123.456.789.11

Or else if you want to access mongo publicly from anywhere you can add 0.0.0.0..

bind_ip = 0.0.0.0 and restart mongo service.

Ram
  • 36
  • 2
0

Yes. i got my problem solved. there was a firewall blocking all incoming requests since my server is new and by default it will be like DENY ALL Policy.

I have added my policy rules to accept from any where as an input chain in iptables then it starts working.

Thank you all for your timely suggestions..!

Ravi kumar
  • 170
  • 1
  • 2
  • 15