Error: '$PORT' is not a valid port number.
kandrenunes
FREEOP

a month ago

When deploying my application, everything shows a "completed" status, but I get the error "Error: '$PORT' is not a valid port number." I believe this is why the application failed to complete.

I've already tried some tips from groups and documentation, but haven't been able to resolve the issue.

  • My railway.toml

[build]

builder = "DOCKERFILE"

dockerfilePath = "Dockerfile"

[deploy]

startCommand = "uvicorn backend.main:app --host 0.0.0.0 --port $PORT"

restartPolicyType = "ON_FAILURE"

restartPolicyMaxRetries = 3

[[volumes]]

mountPath = "/app/dados"

  • dockerfile
EXPOSE 8000  
CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8000"]  
EXPOSE 8000  
CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8000"]  
Could someone help?  
$10 Bounty

12 Replies

Status changed to Open Railway 26 days ago


Remove your custom start command as you already have set up a command in Dockerfile.


brody

Hello, Apologies but we can only do support in English. Please re-submit this ticket using the English language. Best, The Railway Team

kandrenunes
FREEOP

a month ago

Do I just need to remove that section from the railway.toml file?

[deploy]

startCommand = "uvicorn backend.main:app --host 0.0.0.0 --port $PORT"

restartPolicyType = "ON_FAILURE"

restartPolicyMaxRetries = 3


kandrenunes
FREEOP

a month ago

Do I just need to remove that section from the railway.toml file?

[deploy]

startCommand = "uvicorn backend.main:app --host 0.0.0.0 --port $PORT"

restartPolicyType = "ON_FAILURE"

restartPolicyMaxRetries = 3


0x5b62656e5d

Remove your custom start command as you already have set up a command in Dockerfile.

kandrenunes
FREEOP

a month ago

Could you explain to me in practice what I should do? Is the change made in the railway file?


kandrenunes

Do I just need to remove that section from the railway.toml file? \[deploy\] startCommand = "uvicorn backend.main:app --host 0.0.0.0 --port $PORT" restartPolicyType = "ON\_FAILURE" restartPolicyMaxRetries = 3

Just remove the startCommand from your configuration, as your Dockerfile already specifies CMD.


0x5b62656e5d

Just remove the `startCommand` from your configuration, as your Dockerfile already specifies `CMD`.

kandrenunes
FREEOP

a month ago

When deleting the line: startCommand = "uvicorn backend.main:app --host 0.0.0.0 --port $PORT" in the railway.toml file, and then deploying, a CRASHED message appears.


kandrenunes

When deleting the line: startCommand = "uvicorn backend.main:app --host 0.0.0.0 --port $PORT" in the railway.toml file, and then deploying, a CRASHED message appears.

what does the error message say? and yes as the mod says, you shouldn't put the startCommand if you already running the same command in your Dockerfile, also, have you put PORT into variables?


mayoriii

what does the error message say? and yes as the mod says, you shouldn't put the startCommand if you already running the same command in your Dockerfile, also, have you put PORT into variables?

kandrenunes
FREEOP

25 days ago

Error I noticed in the logs:

from core import *.ModuleNotFoundError: No module named 'core'

Something I still don't quite understand.

According to the moderator, is it enough to remove the command line in the railway.toml file and then redeploy it?


kandrenunes

Error I noticed in the logs: from core import \*.ModuleNotFoundError: No module named 'core' Something I still don't quite understand. According to the moderator, is it enough to remove the command line in the railway.toml file and then redeploy it?

I assume your Docker container starts successfully locally?


0x5b62656e5d

I assume your Docker container starts successfully locally?

kandrenunes
FREEOP

25 days ago

What should I do to get the application online?


Well firstly, does your Docker container start properly in a local environment?


0x5b62656e5d

Well firstly, does your Docker container start properly in a local environment?

kandrenunes
FREEOP

25 days ago

This error occurred when I ran pip install -r requirements.txt

Building wheels for collected packages: pydantic-core

Building wheel for pydantic-core (pyproject.toml) ... error

error: subprocess-exited-with-error

× Building wheel for pydantic-core (pyproject.toml) did not run successfully.

│ exit code: 1

╰─> [53 lines of output]

Python reports SOABI: cp314-win_amd64

Computed rustc target triple: x86_64-pc-windows-msvc

Installation directory: C:\Users\User\AppData\Local\puccinialin\puccinialin\Cache

Rustup already downloaded

Installing rust to C:\Users\User\AppData\Local\puccinialin\puccinialin\Cache\rustup

warn: It looks like you have an existing rustup settings file at:

warn: C:\Users\User\AppData\Local\puccinialin\puccinialin\Cache\rustup\settings.toml

warn: Rustup will install the default toolchain as specified in the settings file,

warn: instead of the one inferred from the default host triple.

warn: installing msvc toolchain without its prerequisites

info: profile set to minimal

info: setting default host triple to x86_64-pc-windows-msvc

warn: Updating existing toolchain, profile choice will be ignored

info: syncing channel updates for stable-x86_64-pc-windows-msvc

info: default toolchain set to stable-x86_64-pc-windows-msvc

Checking if cargo is installed

cargo 1.95.0 (f2d3ce0bd 2026-03-21)

Rust not found, installing into a temporary directory

Running maturin pep517 build-wheel -i C:\Users\User\AppData\Local\Programs\Python\Python314\python.exe --compatibility off

📦 Including license file LICENSE

ðŸ\x8d¹ Building a mixed python/rust project

🔗 Found pyo3 bindings

ðŸ\x90\x8d Found CPython 3.14 at C:\Users\User\AppData\Local\Programs\Python\Python314\python.exe

📡 Using build options features, bindings from pyproject.toml

Compiling target-lexicon v0.12.9

Compiling autocfg v1.1.0

Compiling cc v1.0.79

Compiling proc-macro2 v1.0.76

Compiling once_cell v1.18.0

Compiling unicode-ident v1.0.10

Compiling heck v0.4.1

Compiling windows_x86_64_msvc v0.48.0

Compiling version_check v0.9.4

error: linker link.exe not found

|

= note: program not found

note: the msvc targets depend on the msvc linker but link.exe was not found

note: please ensure that Visual Studio 2017 or later, or Build Tools for Visual Studio were installed with the Visual C++ option

note: VS Code is a different product, and is not sufficient

Compiling rustversion v1.0.13

error: could not compile proc-macro2 (build script) due to 1 previous error

warning: build failed, waiting for other jobs to finish...

error: could not compile windows_x86_64_msvc (build script) due to 1 previous error

error: could not compile target-lexicon (build script) due to 1 previous error

error: could not compile rustversion (build script) due to 1 previous error

💥 maturin failed

Caused by: Failed to build a native library through cargo

Caused by: Cargo build finished with "exit code: 101": "cargo" "rustc" "--profile" "release" "--features" "pyo3/extension-module" "--message-format" "json-render-diagnostics" "--manifest-path" "C:\\Users\\User\\AppData\\Local\\Temp\\pip-install-hp0f33fn\\pydantic-core_1e9db8aead08427e88902b2561aad675\\Cargo.toml" "--lib" "--crate-type" "cdylib"

Error: command ['maturin', 'pep517', 'build-wheel', '-i', 'C:\\Users\\User\\AppData\\Local\\Programs\\Python\\Python314\\python.exe', '--compatibility', 'off'] returned non-zero exit status 1

[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.

ERROR: Failed building wheel for pydantic-core

Failed to build pydantic-core

error: failed-wheel-build-for-install

× Failed to build installable wheels for some pyproject.toml based projects

╰─> pydantic-core


Welcome!

Sign in to your Railway account to join the conversation.

Loading...