Fix MongoDB port for remote access in iptables [firewalld] ubuntu

Just add 27017/tcp to iptable and it will work!

sudo firewall-cmd --zone=public --add-port=27017/tcp --permanent
sudo firewall-cmd --reload

Check using: sudo iptables -L -v and/or sudo firewall-cmd --list-ports
Check if firewalld is running: sudo systemctl status firewalld 
tested on: ubuntu: 22.04.1 LTS

Make sure you have disable ufw: sudo ufw disable

 

Errors:

E-1: connect ECONNREFUSED

S-1:

chown -R mongodb:mongodb /var/lib/mongodb
chown mongodb:mongodb /tmp/mongodb-27017.sock

Leave a Reply

Your email address will not be published. Required fields are marked *