How Can I Open A Port On Ubuntu?
Is anything listening on port 8888? If nothing is listening on the port you can't connect to it.
You can check if anything is listening on that port with
sudo netstat -tulpn
The port is likely open already as linux firewalls won't block localhost if you don't ask them to block it.
Related videos on Youtube
Onorio Catenacci
Updated on September 18, 2022Comments
-
Onorio Catenacci over 1 year
Ubuntu 13.04:
No LSB modules are available Distributor ID: Ubuntu Description: Ubuntu 13.04 Release: 13.04 Codename: raring
I'm attempting to open port 8888 on an Ubuntu VM that I'm accessing with VirtualBox/Vagrant. On the vm, I run the following command
vagrant@vagrant-ubuntu-raring-32:~$ curl -v 'http://localhost:8888'
and I get the following response:
* About to connect() to localhost port 8888 (#0) * Trying 127.0.0.1... * Connection refused * Failed connect to localhost:8888; Connection refused * Closing connection 0 curl: (7) Failed connect to localhost:8888; Connection refused
So I then try this (per an answer I found here on AskUbuntu):
sudo ufw allow 8888/tcp
Then I retry the curl command and I get the same thing. Not that it should make any difference but I sudo the curl command and it makes no difference. I've also reverted the machine to baseline and then run
sudo ufw allow 8888
and that doesn't work either. Are there other things which might be blocking that port?-
Braiam about 10 yearsLocalhost doesn't have firewall by default. Are you sure a process is listening that port? Add the output of
lsof -i:8888
to your question. -
Onorio Catenacci about 10 years@Braiam as falconer guessed (and you're right too), I needed to have something listening on that port. Seems obvious now but for some reason it didn't occur to me that the connection would be refused unless someone were listening.
-