localhost on MacOSX connection refused - macos

I've had my app running on localhost port 80 via nginx on my mac for quite awhile. Recently I did some software updates and was trying to run other apps on different ports and now I can't run my first app on localhost:80.
I've very confused on where to start but think this is a firewall issue based on the following:
Tims-MacBook-Pro-2:html TimPeterson$ telnet localhost 80
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying fe80::1...
telnet: connect to address fe80::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host
pointing the browser to http://localhost gives this Oops! Google Chrome could not connect to localhost
thoughts?

you may want to run
apachectl configtest
first.

My problem was specific, but might help another user. On Mac OS go to system preferences/sharing and check your computer name/localhost name (click edit to see the localhost name). My computer was reset by Apple in a non-English speaking country. They stuck some of their language in my computer name (great idea!) and it broke the Cisco login to localhost

What worked for me was uncommenting the following line in my /etc/hosts file:
::1 localhost

Related

XAMPP receives "Connection refused" when curling other localhosts

I've a Reactjs app (NodeJS) running on localhost:3000 as well as a local blockchain node (Hardhat) running on localhost:8545.
There's no issues with those two communicating with each other, but I also have a XAMPP server running locally on localhost:8080 with a php app that returns some values.
I can reach all these localhosts fine through the browser.
But I need the php to communicate with my blockchain node. But the connection keeps getting refused when Xampp tries to create the connection to the node.
I even tried a basic curl from Xampp's terminal, and Xampp can't reach the other localhosts at all (tried both http://localhost:port and http://127.0.0.1:port). For instance if I just wanted to curl my react app (html) from Xampp's terminal like this...
curl http://localhost:3000/ -v
I get this...
* Trying ::1...
* TCP_NODELAY set
* connect to ::1 port 3000 failed: Connection refused
* Trying 127.0.0.1...
* TCP_NODELAY set
* connect to 127.0.0.1 port 3000 failed: Connection refused
* Failed to connect to localhost port 3000: Connection refused
* Closing connection 0
curl: (7) Failed to connect to localhost port 3000: Connection refused
Yes, I can curl things like google.com fine from within Xampp's terminal with no issues. It's just my localhosts. Yes, I have enabled curling in php. Yes, I can curl my react app (html) just fine from a separate terminal window. I'm on MacOS 12.1.
Thanks in advance for any help!!
Edit: I did some research, and I believe the issue is that the Xampp virtual machine can't reach my localhost. I've tried resolving this at the host file level to redirect a domain name to 127.0.0.1, but that doesn't work either. I'm still stuck, but wanted to put an update in case this info is helpful.
Last edit: I gave up.

can't connect to postgres on windows10

I am setting up project on my windows PC and I have a problem with postgres.
Project is set on docker.
when I run docker-compose up I receive error
: *** Failed to connect to database dev; trying to create database
/usr/local/bundle/gems/sequel-4.48.0/lib/sequel/adapters/postgres.rb:224:in `initialize': PG::ConnectionBad: could not connect to server: Connection refused (Sequel::DatabaseConnectionError)
Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?
could not connect to server: Cannot assign requested address
Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432?
I don't know what to do. I have already installed microsoft easy-fix for TCP-IP, shut down windows firewall, changed all connection in pg_hba.conf to trust. Nothing helps. I don't have any antivirus software installed.
nmap report:
Nmap scan report for localhost (127.0.0.1)
Host is up (0.0027s latency).
Other addresses for localhost (not scanned): ::1
Not shown: 995 closed ports
PORT STATE SERVICE
135/tcp open msrpc
445/tcp open microsoft-ds
2068/tcp open avocentkvm
2179/tcp open vmrdp
5432/tcp open postgresql
edit:
I run psql -h localhost and received
psql: CATASTROPHIC: role "Kamil" does not exist
Kamil is my PC name.
edit2:
is it possible that docker doesn't have access to postgres on localhost?
problem solved
I had to set environment var to DB_HOST=docker.for.win.localhost

Connection refused for 127.0.0.1 on OSX Yosemite

I'm on a really strange situation.
I'm using MAMP and I can't access to my working directory from the 127.0.0.1.
When I'm using localhost instead of 127.0.0.1 it works because the localhost is redirected to the ::1 ipv6 address.
So, I can access to my local server only via ipv6.
I've tried to start a little server with Python and it doesn't work ( it works fine on my personal laptop using OSX El Captain ).
When I try with an other port than 80 it works but I need to use this port ..
It's not a conflict, when I'm running the Python server he is the only one to listen the port 80
Do you have an idea about this trouble ?
Why I can use the ipv6 local address only ?

Why does oracle connection opens so slow on mac os sierra?

I work on Docker with an oracle-xe-11g image. When I connect via ssh to Docker container, the connection is established immediately. But when I want to connect to oracle database using localhost:49162 ( port is forwarded to container's 1521 ) it will take about 15 - 25 seconds to open each connection.
It doesn't matter if I use JDBC connection or SQLDeveloper.
I have read that problem could be connected with DNS resolution, but I wasn't able to find any sufficient solution.
Slow DNS lookups
My hosts file:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
My resolv.conf:
search home
nameserver 62.179.1.60
nameserver 62.179.1.61
System version:
macOS Sierra 10.12.3.
Has someone faced similar issues?
In my case, When I followed the link you mentioned in the question, and in particular when I changed the first line of my /etc/hosts of my mac from:
127.0.0.1 localhost
to:
127.0.0.1 localhost Muhammads-MacBook-Pro.local
Where Muhammads-MacBook-Pro.local is the output of the command hostname
Then it worked fine.

ftp - connection refused on Mac

If I run ftp localhost on Mac terminal, it shows the following result.
Trying ::1...
ftp: Can't connect to `::1': Connection refused
Trying 127.0.0.1...
ftp: Can't connect to `127.0.0.1': Connection refused
ftp: Can't connect to `localhost'
I already have apache installed on Mac, and I checked that out by entering localhost on the browser.
How do you diagnose this matter, and what should I take for the next step?
PS some people might ask me about the firewall. I checked that out as well in the system preferences and it's off.

Resources