mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-03 21:25:13 +00:00
Failed to bind to address http://127.0.0.1:5000: address already in use #863
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ZedZipDev on GitHub (Mar 30, 2023).
Originally assigned to: @GregorBiswanger on GitHub.
23.6.1. Thank you for the version!
I have a small NET 6 client app which connects to a NET Web service on other machine.
It works in Windows, ok.
I have build in Windows for Linux:
Finally received:
Unhandled exception. System.IO.IOException: Failed to bind to address http://127.0.0.1:5000: address already in use.
---> Microsoft.AspNetCore.Connections.AddressInUseException: Address already in use
After a search I can say : I do not use this address and port. Also, why it busy - I have no clue.
What is ti and how to fix it?
@ZedZipDev commented on GitHub (Mar 30, 2023):
It was my not started app, ok. I have killed the process and run app again (in terminal)
But I do not see a GUI, the console output only:
info: Microsoft.Hosting.Lifetime[0]
Application is shutting down...
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
Content root path: /home/xoleg/Moomoo/Desktop/linux-unpacked/resources/bin/
Btw, when I have built for windows and run it - it works fine
@GregorBiswanger commented on GitHub (Mar 30, 2023):
This is from ASP.NET Core. When it is launched in production, it has the default ports 5000 and 5001. You can also influence this yourself. Add the following line of code to your
Program.cs:webBuilder.UseUrls("http://0.0.0.0:<port>");Please tell me if it worked.
@GregorBiswanger commented on GitHub (Mar 30, 2023):
Or better yet, via the
appsettings.json, try this instead.@ZedZipDev commented on GitHub (Mar 30, 2023):
Thank you Gregor, please read my 2nd question here: why I see the console output only in Ubuntu instead of GUI?
In the same time I can build and run a desktop app in windows- OK!
I even can provide you my zipped project to check if needed
@GregorBiswanger commented on GitHub (Mar 30, 2023):
To run a Linux desktop application in WSL2 (Windows Subsystem for Linux 2) with a graphical user interface (GUI), you need to install an X Window System server for Windows, which will act as a display server for the Linux applications. One of the popular options is VcXsrv. Here are the steps to run a Linux desktop application with a graphical user interface in WSL2:
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0.0electronize startThe application should now be displayed on your Windows desktop in its own window. Note that while this method works for many applications, some may experience performance or compatibility issues.
Alternatively, you can use Windows 11, which provides native support for WSLg (Windows Subsystem for Linux GUI). This allows for easy running of Linux GUI applications directly from WSL without needing to install a separate X Window System server. You can find more information here: https://aka.ms/wslg
@ZedZipDev commented on GitHub (Mar 30, 2023):
Thank you. but in my case I have a physical machine with Ubuntu in a LAN And I wanted to do real experiment to build my Desktop app Windows for Linux, copy it to Ubuntu and run. All works but I do not see GUI. The same desktop app build for win works fine.
@GregorBiswanger commented on GitHub (Mar 30, 2023):
If you have a physical machine running Ubuntu in your local network and you want to run a Linux desktop application with GUI from your Windows machine, you can use a remote desktop protocol like VNC or X11 forwarding over SSH to display the GUI on your Windows machine. I'll explain both methods below.
Method 1: VNC
vncserverFollow the prompts to set a password for remote access.
Install a VNC client on your Windows machine. For example, you can use RealVNC Viewer: https://www.realvnc.com/en/connect/download/viewer/
Launch the VNC client on your Windows machine and enter the IP address of your Ubuntu machine followed by the display number (e.g., 192.168.1.100:1). Enter the password you set earlier when prompted.
The Ubuntu desktop should now be displayed on your Windows machine, and you can run the Linux desktop application with GUI.
Method 2: X11 Forwarding over SSH
electronize startThe application's GUI should now be displayed on your Windows machine.
Please note that both methods may have some latency or performance issues depending on your network conditions. If you are building a cross-platform application, consider using a framework like Electron or Qt that allows you to build and test the application natively on both Windows and Linux.
@ZedZipDev commented on GitHub (Mar 30, 2023):
Thank you, my case is much simpler: I have built my app for linux, copied to Ubuntu machine (physical), go to (zu Fuss) the Ubuntu , open the directory. double click on executable file - silence. Then I have found it in terminal, run >./mysvc it runs and shows me console output only. Finally: I cannot see GUI. But in windows it works fine.
@GregorBiswanger commented on GitHub (Mar 30, 2023):
How did you create your project for Linux? Do you have the .NET SDK and your project on the Linux? Electron.NET CLI installed and
electronize startexecuted? Or on the Linuxelectronize build /target linux?@ZedZipDev commented on GitHub (Mar 31, 2023):
Hi,
I work in Windows 10. All NET SDK installed. The freshest Electron Cli installed too and i use in my project the freshest NuGet.
My tests: (build an app for Windows or Linux but working in Windows)
I can send you my project zip.
@GregorBiswanger commented on GitHub (Mar 31, 2023):
Okay, the same directory on the machine for different platforms still has difficulties. I'll add support for that.
Please try the following steps:
1, Copy your project to a new directory
2, At the new directory, delete the obj directory
3, Now try
electronize startfrom Linux from the new directoryDoes this work?
@ZedZipDev commented on GitHub (Mar 31, 2023):
What is interesting: again appeared disconnect etc... during the building.
Please see in attached file
eNET.txt
@ZedZipDev commented on GitHub (Mar 31, 2023):
I work on Windows and have an idea to provide my app for windows, linux and macos users. So I have a building environment on my Windows machine. I will do what you recommended on windows machine.
@GregorBiswanger commented on GitHub (Mar 31, 2023):
electron-builder wants to download the native Electron for bundling.. probably won't get access
@GregorBiswanger commented on GitHub (Mar 31, 2023):
For Mac build you need an Mac device
@ZedZipDev commented on GitHub (Mar 31, 2023):
Btw, yesterday I did not see this kind of messages.
I.e. I can build for Win and Linux using Windows , but for MacOS - I should use MacOS. Correct?
@GregorBiswanger commented on GitHub (Mar 31, 2023):
Yes, MacOS... But according to the Apple license, the MacOS must also run on a Mac and only then can you create builds for it... It's a legal matter... Technically, everything would also work with a VM and MacOS ;)
@ZedZipDev commented on GitHub (Apr 5, 2023):
Hi Gregor,
Its me again ;-)
I have made as you recommended above:
Btw. I am still hoping to build Desktop app for linux working in Windows (as it was available some years ago in Electron.NET)
@GregorBiswanger commented on GitHub (Apr 5, 2023):
Do you mean with WSL2?
@ZedZipDev commented on GitHub (Apr 6, 2023):
I work in W10.
I develop a Blazor app. Finally I'd like to build it as a Desktop application - exe for windows and provide to users.
Ok, I do on my machine:
Copy the output folder and give it , user run exe on their Windows machine - OK. Desktop GUI works fine
Also, I have Linux users , I build the Desktop for linux on my machine
@GregorBiswanger commented on GitHub (Apr 6, 2023):
I have now tested it locally with Windows 11 - WSL2 + WSLg and Ubuntu 22.04.2 and the Electron.NET demo app opens.
But please try to install Node and .NET SDK on ubuntu and build from Linux. I couldn't build on Windows for Linux. I got an error.
@ZedZipDev commented on GitHub (Apr 6, 2023):
Ah, I see. Some years ago it was possible: to build for win and linux on W10 and it worked.
I will try. Btw, can I build for Linux using WSL in the same W10? and then copy a folder to Ubuntu?
But do you have a plan to do it possible again: to build for linux on win?
@GregorBiswanger commented on GitHub (Apr 6, 2023):
Good question, I just noticed today that it probably doesn't work anymore?! Whereby WSL2 is a good compromise, which can also be tested straight away.
@ZedZipDev commented on GitHub (Apr 6, 2023):
Great, I and many other wait it. ;-)
@GregorBiswanger commented on GitHub (Apr 6, 2023):
we can't change anything about that, it comes from electron-builder. If so then you would need to contact the owner of it.
@ZedZipDev commented on GitHub (Apr 22, 2023):
Hi Gregor,
I work in W10, I can build (electronize) an app for windows - OK.
Also, in the same W10 I can build (electronize) the same app for Linux using WSL2 and then copy/provide it for Linux users.
Is this correct?
@ZedZipDev commented on GitHub (May 19, 2023):
Hi Gregor,
Is it in your plans to fix it?
@ZedZipDev commented on GitHub (Jun 26, 2023):
Hi everybody, is any progress for this issue?
@FlorianRappl commented on GitHub (Nov 1, 2025):
Outdated - use
ElectronNET.CoreandElectronNET.Core.AspNet.See Wiki / What's New.