Ktor: IllegalArgumentException: Neither port nor sslPort specified.

Created on 5 Dec 2018  路  11Comments  路  Source: ktorio/ktor

For Ktor 1.0.0 server, java version 1.8.0_181 (running server on localhost, Ubuntu 18.04.1 LTS)

Facing the following issue:

Exception in thread "main" java.lang.IllegalArgumentException: Neither port nor sslPort specified. Use command line options -port/-sslPort or configure connectors in application.conf
    at io.ktor.server.engine.CommandLineKt$commandLineEnvironment$environment$1.invoke(CommandLine.kt:121)
    at io.ktor.server.engine.CommandLineKt$commandLineEnvironment$environment$1.invoke(CommandLine.kt)
    at io.ktor.server.engine.ApplicationEngineEnvironmentBuilder.build(ApplicationEngineEnvironment.kt:95)
    at io.ktor.server.engine.ApplicationEngineEnvironmentKt.applicationEngineEnvironment(ApplicationEngineEnvironment.kt:40)
    at io.ktor.server.engine.CommandLineKt.commandLineEnvironment(CommandLine.kt:50)
    at io.ktor.server.netty.EngineMain.main(EngineMain.kt:16)
    at com.gurpreetsk.ApplicationKt.main(Application.kt:36)

However, the application.conf file contains the following:

ktor {
  deployment {
    port = 8080
    port = ${?PORT}
  }
  application {
    modules = [ com.gurpreetsk.ApplicationKt.module ]
  }
}
help wanted

Most helpful comment

There was the same problem after the update of the IDE, it helped "Sync Project with Gradle Files"

All 11 comments

Most likely application.conf is not in the classpath

How do I add it to the classpath? It is not working of a new ktor project either.

Is it placed in a resources source root?

Yes. Attaching project structure screenshot along-with:
screenshot from 2018-12-06 11-01-29

That's quite strange that you have orange test and out directories. For sure something is misconfigured.

application.conf should be in out directory, like this:

screenshot_20181207_151208

I've just tried to create a project using ktor plugin and it runs just fine in IDEA and via gradle as well. Same for website https://start.ktor.io

Let me try and update here in some time if I solve this.

Have you resolved the issue?

No. I still can't figure out what's wrong. However, it seems like a machine issue (wrong PATH or something) as the project runs fine on my other machine.

Hello.
I just update IDEA and ktor plugin and get same issue.
It's my old good working small feature testing project

ktor 1.0.0, Win7 64

I also encountered the same problem. totally do not understand.

There was the same problem after the update of the IDE, it helped "Sync Project with Gradle Files"

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shinriyo picture shinriyo  路  4Comments

guenhter picture guenhter  路  4Comments

dedward3 picture dedward3  路  4Comments

baruchn picture baruchn  路  3Comments

evgfilim1 picture evgfilim1  路  4Comments