R
Railway11mo ago
Dem

socket.gaierror: [Errno -2] Name or service not known

I have a hypercorn app but am encountering this error: socket.gaierror: [Errno -2] Name or service not known. It works when I specify a railway.json that specifies a port, but only on a local host, not on the public domain. How can I fix this?
{
"deploy": {
"startCommand": "hypercorn main:app --bind \"0.0.0.0:8000\""
}
}
{
"deploy": {
"startCommand": "hypercorn main:app --bind \"0.0.0.0:8000\""
}
}
37 Replies
Percy
Percy11mo ago
Project ID: N/A
Brody
Brody11mo ago
you want to use
hypercorn main:app --bind [::]:$PORT
hypercorn main:app --bind [::]:$PORT
Dem
DemOP11mo ago
Hmm same error:
sock.bind(binding)

socket.gaierror: [Errno -2] Name or service not known
sock.bind(binding)

socket.gaierror: [Errno -2] Name or service not known
Brody
Brody11mo ago
show me your new railway.json please
Dem
DemOP11mo ago
{
"deploy": {
"startCommand": "hypercorn main:app --bind [::]:$PORT"
}
}
{
"deploy": {
"startCommand": "hypercorn main:app --bind [::]:$PORT"
}
}
Brody
Brody11mo ago
might need to escape some of it
hypercorn main:app --bind \"[::]:$PORT\"
hypercorn main:app --bind \"[::]:$PORT\"
Dem
DemOP11mo ago
Same thing still
sock.bind(binding)

socket.gaierror: [Errno -2] Name or service not known
sock.bind(binding)

socket.gaierror: [Errno -2] Name or service not known
Brody
Brody11mo ago
hmm that's odd, is that not how it written here? https://github.com/vfehring/fastapi/blob/main/railway.json#L7 if it was wrong we absolutely would have heard of it by now
Dem
DemOP11mo ago
I can try ading the schema and build fields?
Brody
Brody11mo ago
nah that's not the issue
Dem
DemOP11mo ago
Should I ingore this error
No description
Brody
Brody11mo ago
share your repo? replace the railway.app domain with schema.up.railway.app and the error goes away
Dem
DemOP11mo ago
Brody
Brody11mo ago
nope
Dem
DemOP11mo ago
Let me try the new railway json Same thing
Dem
DemOP11mo ago
This is what my repo looksl ike
No description
Brody
Brody11mo ago
delete the procfile that's a heroku thing mainly
Dem
DemOP11mo ago
Ok
Brody
Brody11mo ago
also I'd like the build logs https://bookmarklets.up.railway.app/log-downloader/ before you push this change
Dem
DemOP11mo ago
Oh I already pushed But it's the same error
Brody
Brody11mo ago
how can you be sure that railway is using the correct start command?
Dem
DemOP11mo ago
Do you mean the hypercorn command?
Brody
Brody11mo ago
yes
Dem
DemOP11mo ago
That works locally for me, maybe it's not the correct command for railway though
Brody
Brody11mo ago
I mean, it works here for fastapi
Dem
DemOP11mo ago
When I hard code the port to 8000, it works on railway except I can't access the API on public domain Ya I'm using fastapi Yup
Brody
Brody11mo ago
send your dockerfile?
Dem
DemOP11mo ago
FROM python:3.9

WORKDIR /app

COPY . /app

RUN pip install --trusted-host pypi.python.org -r requirements.txt

RUN apt-get update

RUN apt-get install -y wget unzip

RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

RUN apt install -y ./google-chrome-stable_current_amd64.deb

RUN rm google-chrome-stable_current_amd64.deb

RUN apt-get clean
FROM python:3.9

WORKDIR /app

COPY . /app

RUN pip install --trusted-host pypi.python.org -r requirements.txt

RUN apt-get update

RUN apt-get install -y wget unzip

RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

RUN apt install -y ./google-chrome-stable_current_amd64.deb

RUN rm google-chrome-stable_current_amd64.deb

RUN apt-get clean
Dem
DemOP11mo ago
This is what I get when I hard code to 8000, it runs the code but not accessible on public domain
No description
Brody
Brody11mo ago
may I ask what you are using chrome for?
Dem
DemOP11mo ago
it's for simulating user visits to our site was debugging something sorry
Brody
Brody11mo ago
it not the ideal solution, hard code the port to 8000 and then set a PORT service variable to 8000
Dem
DemOP11mo ago
Got it, thanks!
Brody
Brody11mo ago
let me know if that works
Dem
DemOP11mo ago
That worked! Thank you
Brody
Brody11mo ago
no problem!
Want results from more Discord servers?
Add your server