Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Bug: unable to access "localhost:port" #10

Closed
yacmov opened this issue May 28, 2024 · 4 comments · May be fixed by #11
Closed

Bug: unable to access "localhost:port" #10

yacmov opened this issue May 28, 2024 · 4 comments · May be fixed by #11
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@yacmov
Copy link
Collaborator

yacmov commented May 28, 2024

Note

This issue doesn’t occur when I try to use it with PyCharm
But With VS Code has problem

System

Main system Test system using different IDE Test system using different platform
macOS macOS Windows 11 Arm
VS Code Pycharm VS Code

Description

Understanding the Problem

  • Port Conflict: As I mentioned, common port usage by VS Code extensions and macOS(3000, 5000, etc) can lead to conflicts. I've Identified can use port 5001 in both systems.
  • Configuration File Issue: The Inability to access the application suggests the configuration file config.example.ini might not be read correctly due to a path issue.
  • Path Handling Differences: While PyCharm and VS Code handle paths slightly differently.

Screenshot 1 - using port 5000 both PyCharm and VS Code on macOS

image

Screenshot 2 - using port 5001 with VS Code on macOS
ErrorCode: FileNotFoundError

image

Screenshot 3 - using port 5001 with PyCharm on macOS
image

Solutions

  1. Verify Port Usage:
  • Use alternative port ex: 5001, 5002 etc.
  • To avoid error code added code to check platform then if windows, use 5000 and macOS/Linux use 5002
  1. Resolve Configuration File Path:

Screenshot 4 - problem with relative path with VS Code on macOS
image

  • Change to absolute path will solve the problem.

app.py
image

utils.py
image
image

  1. Pull requests
@yacmov yacmov added bug Something isn't working good first issue Good for newcomers labels May 28, 2024
@yacmov yacmov self-assigned this May 28, 2024
@rafrafavi
Copy link

can you include the specific error message and/or a screenshot? Have you triaged which area of the code is likely to be affected?

@adikal25
Copy link

Try changing your port number to 5001 since 5000 might already be in use
python run app.py --port 5001

@yacmov
Copy link
Collaborator Author

yacmov commented May 28, 2024

can you include the specific error message and/or a screenshot? Have you triaged which area of the code is likely to be affected?

@rafrafavi I added more information to the top page with screenshots. And also find which area of code will be affected. Could you please have a look for me?

Try changing your port number to 5001 since 5000 might already be in use python run app.py --port 5001

@adikal25 Yes, I am using 5001 and 5002 instead of 5000 to run the app. And I thought if the app found macOS or Linux straightaway run 5001 or 5002 instead of run 5000 with error. How do you think?

@adikal25
Copy link

can you include the specific error message and/or a screenshot? Have you triaged which area of the code is likely to be affected?

@rafrafavi I added more information to the top page with screenshots. And also find which area of code will be affected. Could you please have a look for me?

Try changing your port number to 5001 since 5000 might already be in use python run app.py --port 5001

@adikal25 Yes, I am using 5001 and 5002 instead of 5000 to run the app. And I thought if the app found macOS or Linux straightaway run 5001 or 5002 instead of run 5000 with error. How do you think?

@rafrafavi with this code it should solve the above problem
if name == 'main':
port = 5000
if os.name == 'posix':
port = 5001 # or 5002 as needed
app.run(port=port)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
4 participants