Open Port in Ubuntu

ubuntu open port 8080
ubuntu iptables open port
ubuntu list open ports
ubuntu open port 5000
ubuntu check open ports
ubuntu open port 22
ufw open port
ubuntu ufw inactive

So I'm using AWS using EC2 and I'm trying to open up a port for Postgresql. In AWS I already have it open:

TCP
Port (Service)      Source                  Action
0 - 65535           sg-92aadda2 (default)   Delete
22 (SSH)            0.0.0.0/0               Delete
80 (HTTP)           0.0.0.0/0               Delete
5432                0.0.0.0/0               Delete

When I do netstat it looks as though the port is listening:

# netstat -an | grep 5432
tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN

When I do a localhost nmap I get the following:

 Nmap scan report for localhost (127.0.0.1)
 Host is up (0.000010s latency).
 Not shown: 997 closed ports
 PORT      STATE SERVICE
 22/tcp    open  ssh
 80/tcp    open  http
 5432/tcp  open  postgresql

And here's where the fun begins. When I do an nmap from an alternative host I get the following:

PORT      STATE  SERVICE
22/tcp    open   ssh
80/tcp    open   http
5432/tcp  closed postgresql

I also looked at my iptables to see if I was missing something, but the iptables look empty (which should mean they aren't really doing much)

$ iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere
REJECT     all  --  anywhere             127.0.0.0/8          reject-with icmp-port-unreachable
ACCEPT     all  --  anywhere             anywhere             state RELATED,ESTABLISHED
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:http
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:https
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:ssh
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:postgresql
ACCEPT     icmp --  anywhere             anywhere
LOG        all  --  anywhere             anywhere             limit: avg 5/min burst 5 LOG level debug prefix "iptables denied: "
DROP       all  --  anywhere             anywhere

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
DROP       all  --  anywhere             anywhere

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere

Am I missing something cause I can't seem to figure out how to access the ip. Whenever I try I get the following error:

Is the server running on host "xx.xx.xx.xx" and accepting TCP/IP connections on port 5432?

How do I make it so that I can open up the port so that external servers have access to it? Thanks in advance =) Lemme know if you need any additional data.

EDIT: As asked below, I tested telnetting, and I was able to telnet into the localhost, but when attempting from the outside I get:

$ telnet xx.xx.xx.xx 5432
Trying xx.xx.xx.xx...
telnet: Unable to connect to remote host: Connection refused

Also, I double checked and I was properly able to telnet into ssh:

$ telnet xx.xx.xx.xx 22
Trying xx.xx.xx.xx...
Connected to xx.xx.xx.xx.
Escape character is '^]'.
SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.1

Edit /etc/postgresql/<version>/main/postgresql.conf and set the listen_addresses to your outgoing interface or all. Restart postgresql: sudo service postgresql restart.

How To: Ubuntu Linux Firewall Open Port Command, How do I open port 80 and 443 on a Ubuntu Linux LTS version 14.04 server? Ubuntu Linux server comes with firewall configuration tool called  In some cases, ports that are not in use will stay open which may lead to them being exploited… Ubuntu comes with some default commands that can be used to scan your servers for open ports.. The steps below will show you how to use some of these commands to identify listening ports and how find them..

It works for me the last method (thks Julio):

Edit: postgresql.conf

sudo nano /etc/postgresql/9.3/main/postgresql.conf

Enable or add:

listen_addresses = '*'

Restart the database engine:

sudo service postgresql restart


Besides, you can check the file: pg_hba.conf

sudo nano /etc/postgresql/9.3/main/pg_hba.conf

And add your network or host address:

host all all 192.168.1.0/24 md5

How to open some ports on Ubuntu?, Ubuntu these days comes with ufw - Uncomplicated Firewall. ufw is an easy-to-​use method of handling iptables rules. Try using this command  On Ubuntu all ports are opened unless you have a firewall or application that is blocking it. Under normal circumstances, the application running on the port is for LISTENING . So that it can receive from the port.

If you have edited postgresql.conf and main/pg_hba.conf and still having a problem, please try

sudo ufw allow 5432/tcp

to unblock psql port

How to Set Up a Firewall with UFW on Ubuntu 18.04, Instructions. Example 1. Open incoming TCP port 10000 to any source IP address: $ sudo ufw allow from any to any port 10000 proto tcp. Example 2. Open incoming TCP port 443 to only specific source IP address eg. Example 3. Open incoming UDP port 53 to source subnet eg. Example 4. List All UFW rules. Delete UFW rule. Paying attention to which ports are listening on your network is important as open ports can be evidence of an intrusion on your network. Knowledge of the Linux open ports and the kind of information being sent out helps you to thwart malicious efforts aimed at your system. Knowing this is an important part of securing your system.

How to Open/Allow incoming firewall port on Ubuntu 18.04 Bionic , Ubuntu comes with a firewall configuration tool called UFW (Uncomplicated Firewall). In this Duration: 1:51 Posted: Oct 11, 2019 H ow do I open port 80 and 443 on a Ubuntu Linux LTS version 14.04 server? Ubuntu Linux server comes with firewall configuration tool called ufw (Uncomplicated Firewall). It is the default tool. ufw is very easy to use and configure host based firewall settings.

How to open port in Ubuntu, Locating and blocking unwanted open ports in Linux should be a task there is to locating and closing a listening port on Ubuntu Server 18.04. How do I open ssh 22/TCP port using ufw on Ubuntu or Debian server? UFW is an acronym for uncomplicated firewall. It is used for managing a Linux firewall and aims to provide an easy to use interface for the user.

Firewall, nmap · Install nmap. Nmap ("Network Mapper") is a free and open source utility for network exploration or security auditing. nmap 192.168.1.33  Open the YaST tool by issuing the following command: yast; Click Security and Users > Firewall. Select the Allowed Services tab and click Advanced. Enter the desired port range in the from-port-start:to-port-end format and specify the protocol (TCP or UDP). For example, enter 60000:60010 to open ports 60000 to 60010.

Comments
  • you're missing an actual question, so it's not entirely clear what you want us to answer. Additionally, "Whenever I try I get the following error:" what are you trying that gives you that error? Have you tried to telnet into the server? Also, there's not much in your iptables, but if you have a default deny enabled then nothing is getting to that box EXCEPT what is specified to be allowed in your iptables
  • @RussellUhl Sorry, I thought I had asked it, but apparently not. I've added the question at the end. I have not tried telnetting into the server. I'll try that now.
  • no worries. I edited my comment above to include something on your iptables. Make sure you check that as well
  • I'm afraid I'm at a loss, sorry. Make sure you close your firewall back up to where it was before until you find a solution
  • @Aram looks like we were at the same speed with the comment above :)
  • This was also helping for me: cyberciti.biz/tips/…
  • Just a comment for anyone doing this: the listen_addresses IP address parameter is the one that posgresql is listening from (the INPUT destination in iptables syntax), not the IP that it is listening to (the INPUT source).