This is a guide to help those who get the error “Localhost refused to connect” when trying to run certain programs.
1) Computer not connected with internet – Check if your computer or device has been recently updated. Some updates may have broken networking, and this could be the cause of problems connecting on localhost.2) Network connection issues- Make sure you are connected via ethernet cable, 3G data card/plan or 4G data card/plan (not Wi-Fi).3) Firewall software settings – The firewall settings in many operating systems can prevent connections from originating outside your network. For example, Windows’ UAC features can block outbound traffic by default that doesn’t originate from an administrator account (typically used for high level system administration tasks).4) Other users on same machine blocking access – If other users are using up all available ports on their own computers there will be no room for connections through them as well as insufficient port space for new incoming connections5) Port forwarding isn’t enabled – Ports need to be forwarded before they’re accessible6) Your host name doesn’t match what’s set in DNS7)- ISP providing you with bad routing

The “localhost connection refused windows 10” is a problem that has been present for a while. Microsoft has released 7 fixes to fix the issue.

Localhost refused to connect: 7 Fixes

Running a local server configuration like XAMPP or Apache on your system is one of the quickest methods to set up a local server whether you’re a web developer or want to set up a local server on your machine. 

If you can’t access to the localhost page, it’s possible that there’s an issue with your setup or network settings. In this post, we’ll look at the issue “Localhost refuses to connect” and provide a few options to fix it.


There are a number of possible causes for this problem. It might be a permissions issue, where the server configuration files lack the necessary rights to take effect, or it could be as simple as an improper installation. Other frequent causes include the following:

  • On a Windows Server, WSL is installed.
  • Another software is using port 80.
  • The web server is listening on the incorrect port, or any port other than 80.
  • 127.0.0.1 is not connected to localhost.

Also see: 5 Solutions for Getting Windows Ready Stuck


Here are a few options to consider. 

127.0.0.1 is the IP address for localhost.

If you’re having trouble accessing localhost on your machine’s local IP address, use localhost or 127.0.0.1 in the URL bar and try again. 


Try using the port number to connect to localhost.

Another thing you can do with the URL is to include the port number to see if you can direct it in the appropriate place. Add the following port number to the URL:

localhost:[insert port number]

By default, Apache connects to port 80, however it may connect to port 8080 or any other port on certain computers if other applications are already using those ports. 


Restart XAMPP if it hasn’t already.

Restarting your XAMPP installation might also aid in the removal of any bugs or faults that may be giving you problems. Restart the server using the XAMPP or MAMPP management panel if you’re using Windows or Mac. If you’re using Linux, type the instructions below one by one, hitting enter after each one. 

/opt/lampp/lampp stop sudo sudo start /opt/lampp/lampp

Also see: How can I view the history of my command line on Linux?


Allow connections to come in.

Another thing to check, whether on Windows or macOS, is if inbound connections have permission to visit localhost. To safeguard your system, OS firewalls often block all incoming connections, but they often unintentionally prevent your access to localhost. So double-check to verify whether your firewall allows inbound connections. 


Check the port number for Apache.

Another option is to look for the port number for Apache. Here’s how to do it.

Step 1: If you’re using Windows, stop the Apache service by accessing the XAMPP control panel and selecting the Stop button, or use the command below if you’re using Linux.

/opt/lampp/lampp stop sudoLocalhost-refused-to-connect-7-Fixes

Step 2: Go to the following location and open the Apache configuration file:

  • Linux: /opt/lampp/apache/httpd.conf
  • Windows: C://xampp/apache/conf/httpd.conf
  • Mac: Applications/mampp/apache/conf/httpd.conf

1640007379_608_Localhost-refused-to-connect-7-Fixes

Step 3: After you’ve opened the file, check for the following line.

localhost:80 is the name of the server.

Replace this with the following. Note that if you don’t see the line in your Apache setup, you may manually add it.

8080 ServerName localhost:8080 Listen1640007380_263_Localhost-refused-to-connect-7-Fixes

Step 4: Save the file with administrative rights and restart the apache service using the XAMPP control panel on Windows or the command below on Linux.

sudo start /opt/lampp/lampp1640007382_820_Localhost-refused-to-connect-7-Fixes

This should take care of your problem. If you think the default port number (80) is incompatible with another program, this should fix it. Please feel free to allocate Apache to any other available port.


LXSSManager Service should be restarted (Windows)

If you’re using the Windows Subsystem for Linux to run or build web apps, restart the LXSSManager service to see if it fixes the problem. 

To launch the Run prompt, press Windows Key + R. Enter services.msc in the search box. 

1640007382_814_Localhost-refused-to-connect-7-Fixes

Step 2: Locate and double-click the LXSSManager service, then choose Restart. Instead, click Start if the service isn’t currently operating.

1640007384_486_Localhost-refused-to-connect-7-Fixes

Your web server should start operating normally after the service has been restarted. 


Delete the configuration files for Visual Studio (Windows)

The configuration files in Visual Studio may occasionally mess with Apache’s setup, causing your webserver to go down. If you think this is the case, try removing the configuration file from the.vs/config folder to see if it helps. 

Also see: How to Fix the Error ‘Sudo command not found’ on Linux.

Memory-error-0-1766-8-Fixes

When he’s not writing/editing/shooting/hosting all things tech, he streams himself racing virtual vehicles. Yadullah may be reached at [email protected], or you can follow him on Instagram or Twitter.

Watch This Video-

The “localhost refused to connect spring boot” is a problem that has been present for a while. Spring Boot has released 7 fixes to fix the issue.

Frequently Asked Questions

How do I fix localhost error refused to connect?

A: Make sure you are running the latest version of node.js and npm

Why is localhost not connecting?

A: The most likely cause for this is that your localhost doesnt have permission to connect. You may need to change your hosts file and allow it access to the outside world.

  • localhost refused to connect xampp
  • localhost:3000 refused to connect
  • localhost refused to connect visual studio
  • localhost refused to connect chrome
  • localhost refused to connect visual studio code
You May Also Like

Download Pogoplug for PC Windows 10,8,7

Pogoplug is a personal cloud storage server and backup solution for your…

How to Open PowerShell in Windows 11

We all know that you can run PowerShell without opening the Windows…

Have Android 4.4 KitKat on every smartphone by installing the new Google apps

With the release of Android 4.4 KitKat, Google has released a new…

Download Hami Pay for PC Windows 10,8,7

Hami is an open source and free software, designed to help you…